Software /
code /
prosody-modules
Comparison
mod_http_muc_log/mod_http_muc_log.lua @ 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 |
parent | 2763:a6d19aea9b73 |
child | 2836:52a7c0f6aea1 |
comparison
equal
deleted
inserted
replaced
2825:d0c4ecabf3f5 | 2826:ed26608920d4 |
---|---|
74 if retval then | 74 if retval then |
75 return select(retval, iter()); | 75 return select(retval, iter()); |
76 end | 76 end |
77 return iter(); | 77 return iter(); |
78 end | 78 end |
79 | |
80 local lazy = module:get_option_boolean(module.name .. "_lazy_calendar", true); | |
79 | 81 |
80 -- Produce the calendar view | 82 -- Produce the calendar view |
81 local function years_page(event, path) | 83 local function years_page(event, path) |
82 local response = event.response; | 84 local response = event.response; |
83 | 85 |
91 if date_list then | 93 if date_list then |
92 for _, date in ipairs(date_list) do | 94 for _, date in ipairs(date_list) do |
93 local when = datetime.parse(date.."T00:00:00Z"); | 95 local when = datetime.parse(date.."T00:00:00Z"); |
94 local t = os_date("!*t", when); | 96 local t = os_date("!*t", when); |
95 dates:set(t.year, t.month, t.day, when); | 97 dates:set(t.year, t.month, t.day, when); |
98 end | |
99 elseif lazy then | |
100 -- Lazy with many false positives | |
101 local first_day = find_once(room, nil, 3); | |
102 local last_day = find_once(room, { reverse = true }, 3); | |
103 for when = first_day, last_day, 86400 do | |
104 local t = os_date("!*t", when); | |
105 dates:set(t.year, t.month, t.day, when ); | |
96 end | 106 end |
97 else | 107 else |
98 -- Collect date the hard way | 108 -- Collect date the hard way |
99 module:log("debug", "Find all dates with messages"); | 109 module:log("debug", "Find all dates with messages"); |
100 local next_day; | 110 local next_day; |