Changeset

12600:3d3a0c4e2662

Merge 0.12->trunk
author Kim Alvefur <zash@zash.se>
date Fri, 29 Jul 2022 17:10:31 +0200
parents 12596:78f874441e21 (current diff) 12599:5aafcf6a0730 (diff)
children 12601:72f7bb3f30d3
files plugins/mod_storage_sql.lua spec/core_storagemanager_spec.lua
diffstat 3 files changed, 20 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_http_files.lua	Wed Jul 27 00:32:04 2022 +0200
+++ b/plugins/mod_http_files.lua	Fri Jul 29 17:10:31 2022 +0200
@@ -74,8 +74,7 @@
 	if opts.index_files == nil then
 		opts.index_files = dir_indices;
 	end
-	-- TODO Crank up to warning
-	module:log("debug", "%s should be updated to use 'net.http.files' instead of mod_http_files", get_calling_module());
+	module:log("warn", "%s should be updated to use 'net.http.files' instead of mod_http_files", get_calling_module());
 	return fileserver.serve(opts);
 end
 
--- a/plugins/mod_storage_sql.lua	Wed Jul 27 00:32:04 2022 +0200
+++ b/plugins/mod_storage_sql.lua	Fri Jul 29 17:10:31 2022 +0200
@@ -543,8 +543,7 @@
 		SELECT DISTINCT "with", COUNT(*), MIN("when"), MAX("when")
 		FROM "prosodyarchive"
 		WHERE %s
-		GROUP BY "with"
-		ORDER BY "sort_id" %s%s;
+		GROUP BY "with";
 		]];
 		local args = { host, user or "", store, };
 		local where = { "\"host\" = ?", "\"user\" = ?", "\"store\" = ?", };
@@ -557,8 +556,7 @@
 			args[#args+1] = query.limit;
 		end
 
-		sql_query = sql_query:format(t_concat(where, " AND "), query.reverse
-			and "DESC" or "ASC", query.limit and " LIMIT ?" or "");
+		sql_query = sql_query:format(t_concat(where, " AND "));
 		return engine:select(sql_query, unpack(args));
 	end);
 	if not ok then return ok, result end
--- a/spec/core_storagemanager_spec.lua	Wed Jul 27 00:32:04 2022 +0200
+++ b/spec/core_storagemanager_spec.lua	Fri Jul 29 17:10:31 2022 +0200
@@ -575,6 +575,23 @@
 					end
 				end);
 
+				it("the summary api works", function()
+					assert.truthy(archive:delete("summary-user"));
+					local first_sid = archive:append("summary-user", nil, test_stanza, test_time, "contact@example.com");
+					local second_sid = archive:append("summary-user", nil, test_stanza, test_time+1, "contact@example.com");
+					assert.truthy(first_sid and second_sid, "preparations failed")
+					---
+
+					local user_summary, err = archive:summary("summary-user");
+					assert.is_table(user_summary, err);
+					assert.same({ ["contact@example.com"] = 2 }, user_summary.counts, "summary.counts matches");
+					assert.same({ ["contact@example.com"] = test_time }, user_summary.earliest, "summary.earliest matches");
+					assert.same({ ["contact@example.com"] = test_time+1 }, user_summary.latest, "summary.latest matches");
+					if user_summary.body then
+						assert.same({ ["contact@example.com"] = test_stanza:get_child_text("body") }, user_summary.body, "summary.body matches");
+					end
+				end);
+
 			end);
 		end);
 	end