nmlorg / metabot

Modularized, multi-account bot.
https://metabot.readthedocs.io/
5 stars 0 forks source link

Daily announcement updates should differentiate when an event is removed from a view versus from the calendar itself #75

Closed nmlorg closed 5 years ago

nmlorg commented 5 years ago

@realmain has a group that's configured to show any events occurring over the next 60 days, but is restricted to at most 5 events. His group's calendar typically has more than 5 events during that window, so that tends to be the limit on events' view. The logic to check for removed events only checks to see if an event in the previous iteration's view is present in the current view, so for example if at 8 a.m. the bot generates a view for a calendar with:

  1. Alpha Event today at 12 pm
  2. Bravo Event tomorrow at 12 pm
  3. Charlie Event in 2 days at 12 pm
  4. Delta Event in 3 days at 12 pm
  5. Echo Event in 4 days at 12 pm
  6. Foxtrot Event in 60 days at 12 pm

it'll show Alpha, Bravo, Charlie, Delta, and Echo, leaving Foxtrot off because, even though it's within 60 days, it's the 6ᵗʰ event. Then if at 9 a.m. the bot generates a new view for:

  1. Alpha Event today at 12 pm
  2. Zulu Event today at 6 pm
  3. Bravo Event tomorrow at 12 pm
  4. Charlie Event in 2 days at 12 pm
  5. Delta Event in 3 days at 12 pm
  6. Echo Event in 4 days at 12 pm
  7. Foxtrot Event in 60 days at 12 pm

the view will only include Alpha, Zulu, Bravo, Charlie, and Delta, so it will appear as if Echo had been removed from the calendar, generating an update message:

Updated:
  Zulu Event
    • New event!
  Echo Event
    • Removed.

  One possibility would be to query for the event's id to verify it has actually been removed from the calendar versus just dropping out of the view. It might even make sense to force the event back into the view (so the updated daily announcement will include 6 events instead of the 5 it's configured to list), if only to handle the situation where an event is removed from a view because its start date has changed (which probably should be reported). It might make the most sense to do the query, check if anything has actually changed, and force it back into the view if so, otherwise (if nothing has changed—suggesting it has fallen out of the view because of a config change or the addition of a new event) allow it to silently drop out of the announcement.

Another possibility would be to simply ignore removals at the end of the list, but that would lead to incorrectly ignoring events that actually have been deleted if they just happen to be at the end of a view.

However this is resolved, we should keep in mind the related situation of events coming into/leaving a view because of a config change. For example, if @realmain reconfigured his group to show the next 10 events, the 10 a.m. update would currently report:

Updated:
  Echo Event
    • New event!
  Foxtrot Event
    • New event!

and similarly if he dropped it to 3:

Updated:
  Charlie Event
    • Removed.
  Delta Event
    • Removed.

We can probably handle the latter case however we handle the addition of new events pushing existing events out, but the former case would need us to be able to query the calendar as of when the previous announcement was made (to determine that Echo and Foxtrot did actually already exist on the calendar then). There might be something clever we can do here (other than serializing and storing a snapshot of the entire calendar), but it might be that we just do the exists-but-is-now-outside-of-the-view check against the live calendar to properly handle non-removals and live with spurious "New event!" updates.