Mercurial > prosody-modules
changeset 2826:ed26608920d4
mod_http_muc_log: Switch to an inaccurate but O(1) method of producing the calendar view
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 17 Nov 2017 16:30:53 +0100 |
parents | d0c4ecabf3f5 |
children | 45380b77303d |
files | mod_http_muc_log/mod_http_muc_log.lua |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_http_muc_log/mod_http_muc_log.lua Wed Nov 15 22:21:14 2017 +0100 +++ b/mod_http_muc_log/mod_http_muc_log.lua Fri Nov 17 16:30:53 2017 +0100 @@ -77,6 +77,8 @@ return iter(); end +local lazy = module:get_option_boolean(module.name .. "_lazy_calendar", true); + -- Produce the calendar view local function years_page(event, path) local response = event.response; @@ -94,6 +96,14 @@ local t = os_date("!*t", when); dates:set(t.year, t.month, t.day, when); end + elseif lazy then + -- Lazy with many false positives + local first_day = find_once(room, nil, 3); + local last_day = find_once(room, { reverse = true }, 3); + for when = first_day, last_day, 86400 do + local t = os_date("!*t", when); + dates:set(t.year, t.month, t.day, when ); + end else -- Collect date the hard way module:log("debug", "Find all dates with messages");