Mercurial > prosody-hg
comparison plugins/mod_storage_memory.lua @ 10220:1e2b444acb72
mod_storage_*: Tweak :summary API to allow future expansion with more fields
Eg might want to include last message, timestamp, chat state or other info.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 23 Aug 2019 01:04:00 +0200 |
| parents | f6959fe81a1d |
| children | 068692cb9e78 |
comparison
equal
deleted
inserted
replaced
| 10219:d58925bb74ca | 10220:1e2b444acb72 |
|---|---|
| 168 end | 168 end |
| 169 | 169 |
| 170 function archive_store:summary(username, query) | 170 function archive_store:summary(username, query) |
| 171 local iter, err = self:find(username, query) | 171 local iter, err = self:find(username, query) |
| 172 if not iter then return iter, err; end | 172 if not iter then return iter, err; end |
| 173 local summary = {}; | 173 local counts = {}; |
| 174 for _, _, _, with in iter do | 174 for _, _, _, with in iter do |
| 175 summary[with] = (summary[with] or 0) + 1; | 175 counts[with] = (counts[with] or 0) + 1; |
| 176 end | 176 end |
| 177 return summary; | 177 return { |
| 178 counts = counts; | |
| 179 }; | |
| 178 end | 180 end |
| 179 | 181 |
| 180 | 182 |
| 181 function archive_store:delete(username, query) | 183 function archive_store:delete(username, query) |
| 182 if not query or next(query) == nil then | 184 if not query or next(query) == nil then |
