Comparison

plugins/mod_storage_internal.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
parent 10221:068692cb9e78
child 10223:d185c4961ee0
comparison
equal deleted inserted replaced
10221:068692cb9e78 10222:51f145094648
216 216
217 function archive:summary(username, query) 217 function archive:summary(username, query)
218 local iter, err = self:find(username, query) 218 local iter, err = self:find(username, query)
219 if not iter then return iter, err; end 219 if not iter then return iter, err; end
220 local counts = {}; 220 local counts = {};
221 local earliest = {};
221 local latest = {}; 222 local latest = {};
222 for _, _, when, with in iter do 223 for _, _, when, with in iter do
223 counts[with] = (counts[with] or 0) + 1; 224 counts[with] = (counts[with] or 0) + 1;
225 if earliest[with] == nil then
226 earliest[with] = when;
227 end
224 latest[with] = when; 228 latest[with] = when;
225 end 229 end
226 return { 230 return {
227 counts = counts; 231 counts = counts;
232 earliest = earliest;
228 latest = latest; 233 latest = latest;
229 }; 234 };
230 end 235 end
231 236
232 function archive:users() 237 function archive:users()