Changeset

1605:c8a51d1bc96d

mod_http_muc_log: Sort date list in reverse
author Kim Alvefur <zash@zash.se>
date Mon, 09 Feb 2015 00:47:38 +0100
parents 1604:53052a610c67
children 1606:2c8b985ebde5
files mod_http_muc_log/mod_http_muc_log.lua
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mod_http_muc_log/mod_http_muc_log.lua	Sun Feb 08 17:05:21 2015 +0100
+++ b/mod_http_muc_log/mod_http_muc_log.lua	Mon Feb 09 00:47:38 2015 +0100
@@ -101,24 +101,25 @@
 
 	local dates, i = {}, 1;
 	module:log("debug", "Find all dates with messages");
-	local next_day;
+	local prev_day;
 	repeat
 		local iter = archive:find(room, {
-			["start"] = next_day;
+			["end"] = prev_day;
 			limit = 1;
 			with = "message<groupchat";
+			reverse = true;
 		})
 		if not iter then break end
-		next_day = nil;
+		prev_day = nil;
 		for key, message, when in iter do
-			next_day = datetime.date(when);
+			prev_day = datetime.date(when);
 			dates[i], i = {
-				date = next_day;
+				date = prev_day;
 			}, i + 1;
-			next_day = datetime.parse(next_day .. "T23:59:59Z") + 1;
+			prev_day = datetime.parse(prev_day .. "T00:00:00Z") - 1;
 			break;
 		end
-	until not next_day;
+	until not prev_day;
 
 	response.headers.content_type = "text/html; charset=utf-8";
 	return render(template, {