Comparison

plugins/mod_storage_internal.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
parent 10024:4a0d990253a0
child 10221:068692cb9e78
comparison
equal deleted inserted replaced
10219:d58925bb74ca 10220:1e2b444acb72
215 end 215 end
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 summary = {}; 220 local counts = {};
221 for _, _, _, with in iter do 221 for _, _, _, with in iter do
222 summary[with] = (summary[with] or 0) + 1; 222 counts[with] = (counts[with] or 0) + 1;
223 end 223 end
224 return summary; 224 return {
225 counts = counts;
226 };
225 end 227 end
226 228
227 function archive:users() 229 function archive:users()
228 return datamanager.users(host, self.store, "list"); 230 return datamanager.users(host, self.store, "list");
229 end 231 end