# HG changeset patch # User Kim Alvefur # Date 1416509782 -3600 # Node ID 0a6974f2cb550a3ab3a6ba35a6604d793a6a04b7 # Parent 91b91052e0e8527111b6a692a4e71da6e6e27473 mod_http_muc_log: Use archive IDs to find next and previous dates that contain messages diff -r 91b91052e0e8 -r 0a6974f2cb55 mod_http_muc_log/mod_http_muc_log.lua --- a/mod_http_muc_log/mod_http_muc_log.lua Thu Nov 20 19:50:43 2014 +0100 +++ b/mod_http_muc_log/mod_http_muc_log.lua Thu Nov 20 19:56:22 2014 +0100 @@ -264,6 +264,7 @@ }); if not iter then return 500; end + local first, last; local verb, subject, body; for key, item, when in iter do body = item:get_child_text("body"); @@ -286,28 +287,31 @@ st_name = item.name; st_type = item.attr.type; }, i + 1; + first = first or key; + last = key; end + if i == 1 then return end -- No items local next_when = ""; local prev_when = ""; module:log("debug", "Find next date with messages"); for key, message, when in archive:find(room, { - ["start"] = datetime.parse(date.."T00:00:00Z") + 86400; + after = last; + limit = 1; }) do next_when = datetime.date(when); module:log("debug", "Next message: %s", datetime.datetime(when)); - break; end module:log("debug", "Find prev date with messages"); for key, message, when in archive:find(room, { - ["end"] = datetime.parse(date.."T00:00:00Z") - 1; + before = first; + limit = 1; reverse = true; }) do prev_when = datetime.date(when); module:log("debug", "Previous message: %s", datetime.datetime(when)); - break; end response.headers.content_type = "text/html";