Mercurial > prosody-modules
diff mod_http_muc_log/mod_http_muc_log.lua @ 1577:0a6974f2cb55
mod_http_muc_log: Use archive IDs to find next and previous dates that contain messages
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 20 Nov 2014 19:56:22 +0100 |
parents | 91b91052e0e8 |
children | a68ec7a2dc02 |
line wrap: on
line diff
--- 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";