aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_sql.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-08-23 01:15:44 +0200
committerKim Alvefur <zash@zash.se>2019-08-23 01:15:44 +0200
commit9d5e31fd481a38bc7e346697cdacb8ef5cbd1ae5 (patch)
treeace6039a158a113bee6431bec2da2f621f663abe /plugins/mod_storage_sql.lua
parentd3c559bcc89ef91ebecde3cc3b4520873a98ea4d (diff)
downloadprosody-9d5e31fd481a38bc7e346697cdacb8ef5cbd1ae5.tar.gz
prosody-9d5e31fd481a38bc7e346697cdacb8ef5cbd1ae5.zip
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.
Diffstat (limited to 'plugins/mod_storage_sql.lua')
-rw-r--r--plugins/mod_storage_sql.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua
index dc960cad..666cee41 100644
--- a/plugins/mod_storage_sql.lua
+++ b/plugins/mod_storage_sql.lua
@@ -424,7 +424,7 @@ function archive_store:summary(username, query)
local user,store = username,self.store;
local ok, result = engine:transaction(function()
local sql_query = [[
- SELECT DISTINCT "with", COUNT(*), MAX("when")
+ SELECT DISTINCT "with", COUNT(*), MIN("when"), MAX("when")
FROM "prosodyarchive"
WHERE %s
GROUP BY "with"
@@ -447,14 +447,16 @@ function archive_store:summary(username, query)
end);
if not ok then return ok, result end
local counts = {};
- local latest = {};
+ local earliest, latest = {}, {};
for row in result do
local with, count = row[1], row[2];
counts[with] = count;
- latest[with] = row[3];
+ earliest[with] = row[3];
+ latest[with] = row[4];
end
return {
counts = counts;
+ earliest = earliest;
latest = latest;
};
end