Mercurial > prosody-hg
comparison plugins/mod_storage_memory.lua @ 10222:51f145094648
mod_storage_*: Also include timestmap of first message in :summary API
For completeness along with most recent timestamp. Might be nice to be
able to order by oldest unread message.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 23 Aug 2019 01:15:44 +0200 |
| parents | 068692cb9e78 |
| children | 018acdaf374f |
comparison
equal
deleted
inserted
replaced
| 10221:068692cb9e78 | 10222:51f145094648 |
|---|---|
| 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 counts = {}; | 173 local counts = {}; |
| 174 local earliest = {}; | |
| 174 local latest = {}; | 175 local latest = {}; |
| 175 for _, _, when, with in iter do | 176 for _, _, when, with in iter do |
| 176 counts[with] = (counts[with] or 0) + 1; | 177 counts[with] = (counts[with] or 0) + 1; |
| 178 if earliest[with] == nil then | |
| 179 earliest[with] = when; | |
| 180 end | |
| 177 latest[with] = when; | 181 latest[with] = when; |
| 178 end | 182 end |
| 179 return { | 183 return { |
| 180 counts = counts; | 184 counts = counts; |
| 185 earliest = earliest; | |
| 181 latest = latest; | 186 latest = latest; |
| 182 }; | 187 }; |
| 183 end | 188 end |
| 184 | 189 |
| 185 | 190 |
