[mod] reminder logic
This commit is contained in:
parent
29e8daa719
commit
1fe66bc673
|
@ -41,38 +41,45 @@ namespace _munin
|
|||
.reduce((x, y) => x.concat(y), [])
|
||||
);
|
||||
for (const target of targets) {
|
||||
const window_from : lib_plankton.pit.type_pit = lib_plankton.pit.shift_hour(
|
||||
now,
|
||||
0
|
||||
);
|
||||
const window_to : lib_plankton.pit.type_pit = lib_plankton.pit.shift_hour(
|
||||
now,
|
||||
conf.settings.interval
|
||||
);
|
||||
lib_plankton.log._info(
|
||||
"munin.run.iteration",
|
||||
{
|
||||
"details": {
|
||||
"target": target,
|
||||
}
|
||||
}
|
||||
);
|
||||
for (const hours of target.reminders) {
|
||||
const window_from : lib_plankton.pit.type_pit = lib_plankton.pit.shift_hour(
|
||||
now,
|
||||
hours + 0
|
||||
);
|
||||
const window_to : lib_plankton.pit.type_pit = lib_plankton.pit.shift_hour(
|
||||
now,
|
||||
hours + conf.settings.interval
|
||||
);
|
||||
for (const event of events) {
|
||||
const event_begin : lib_plankton.pit.type_pit = lib_plankton.pit.from_datetime(event.begin);
|
||||
lib_plankton.log._debug(
|
||||
"munin.run.check_dueness",
|
||||
{
|
||||
"details": {
|
||||
// "now": lib_plankton.pit.to_date_object(now).toISOString(),
|
||||
"event_begin": lib_plankton.pit.to_date_object(event_begin).toISOString(),
|
||||
"target": target.show(),
|
||||
"window_from": lib_plankton.pit.to_date_object(window_from).toISOString(),
|
||||
"window_to": lib_plankton.pit.to_date_object(window_to).toISOString(),
|
||||
}
|
||||
}
|
||||
);
|
||||
const remind : boolean = lib_plankton.pit.is_between(
|
||||
for (const reminder_hours of target.reminders) {
|
||||
for (const event of events) {
|
||||
const event_begin : lib_plankton.pit.type_pit = lib_plankton.pit.from_datetime(
|
||||
event.begin
|
||||
);
|
||||
const reminder_time : lib_plankton.pit.type_pit = lib_plankton.pit.shift_hour(
|
||||
event_begin,
|
||||
(-reminder_hours)
|
||||
);
|
||||
lib_plankton.log._info(
|
||||
"munin.run.check_dueness",
|
||||
{
|
||||
"details": {
|
||||
"event_begin": lib_plankton.pit.to_date_object(event_begin).toISOString(),
|
||||
"reminder_hours": reminder_hours,
|
||||
"reminder_time": lib_plankton.pit.to_date_object(reminder_time).toISOString(),
|
||||
}
|
||||
}
|
||||
);
|
||||
const remind : boolean = lib_plankton.pit.is_between(
|
||||
reminder_time,
|
||||
window_from,
|
||||
window_to
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue