Software / code / prosody
Comparison
plugins/mod_storage_sql.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 | 10033:ca8333d1a7fe |
| child | 10221:068692cb9e78 |
comparison
equal
deleted
inserted
replaced
| 10219:d58925bb74ca | 10220:1e2b444acb72 |
|---|---|
| 444 sql_query = sql_query:format(t_concat(where, " AND "), query.reverse | 444 sql_query = sql_query:format(t_concat(where, " AND "), query.reverse |
| 445 and "DESC" or "ASC", query.limit and " LIMIT ?" or ""); | 445 and "DESC" or "ASC", query.limit and " LIMIT ?" or ""); |
| 446 return engine:select(sql_query, unpack(args)); | 446 return engine:select(sql_query, unpack(args)); |
| 447 end); | 447 end); |
| 448 if not ok then return ok, result end | 448 if not ok then return ok, result end |
| 449 local summary = {}; | 449 local counts = {}; |
| 450 for row in result do | 450 for row in result do |
| 451 local with, count = row[1], row[2]; | 451 local with, count = row[1], row[2]; |
| 452 summary[with] = count; | 452 counts[with] = count; |
| 453 end | 453 end |
| 454 return summary; | 454 return { |
| 455 counts = counts; | |
| 456 }; | |
| 455 end | 457 end |
| 456 | 458 |
| 457 function archive_store:delete(username, query) | 459 function archive_store:delete(username, query) |
| 458 query = query or {}; | 460 query = query or {}; |
| 459 local user,store = username,self.store; | 461 local user,store = username,self.store; |