aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_storage_internal.lua5
-rw-r--r--plugins/mod_storage_memory.lua5
-rw-r--r--plugins/mod_storage_sql.lua8
3 files changed, 15 insertions, 3 deletions
diff --git a/plugins/mod_storage_internal.lua b/plugins/mod_storage_internal.lua
index 1ee860d6..b3702fe1 100644
--- a/plugins/mod_storage_internal.lua
+++ b/plugins/mod_storage_internal.lua
@@ -218,13 +218,18 @@ function archive:summary(username, query)
local iter, err = self:find(username, query)
if not iter then return iter, err; end
local counts = {};
+ local earliest = {};
local latest = {};
for _, _, when, with in iter do
counts[with] = (counts[with] or 0) + 1;
+ if earliest[with] == nil then
+ earliest[with] = when;
+ end
latest[with] = when;
end
return {
counts = counts;
+ earliest = earliest;
latest = latest;
};
end
diff --git a/plugins/mod_storage_memory.lua b/plugins/mod_storage_memory.lua
index 6a04e003..8beb8c01 100644
--- a/plugins/mod_storage_memory.lua
+++ b/plugins/mod_storage_memory.lua
@@ -171,13 +171,18 @@ function archive_store:summary(username, query)
local iter, err = self:find(username, query)
if not iter then return iter, err; end
local counts = {};
+ local earliest = {};
local latest = {};
for _, _, when, with in iter do
counts[with] = (counts[with] or 0) + 1;
+ if earliest[with] == nil then
+ earliest[with] = when;
+ end
latest[with] = when;
end
return {
counts = counts;
+ earliest = earliest;
latest = latest;
};
end
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