Logistics coordinators pay attention to the short term and long term health of their schedules. In the short term, they look at what shifts need coverage in the next week. In the long term, they look at what shifts need a recurring volunteer and the volunteers that have picked it up in the past. In Rootable, over time, as the data model changed, the shift list page became useless. Clicking on a row on the shift list takes you to the most recent occurrence which is already information we can see on the log.
This makes it difficult to discern which shifts need a recurring volunteer. Its time consuming because you have to check week by week by opening individual tabs for each week. So we want a new shift page that is more helpful.
To figure out what shifts to show, we need to find shifts that are still happening. I created a shift_summaries view that tries to pick an the best event for this shift.
A CTE marks each shift recurring or not, and each event in a shift as recurring or remaining. events.recurring is just "are there recurrence options present". events.remaining tries to figure out based on starts_at, the recurrence options' UNTIL and COUNT.
Then in the main query, it filters out events based on shifts.recurring, the events.recurring, and if the event (likely) has events.remaining occurrences left.
The full details of how are outlined in db/views/shift_summaries_v01.sql and spec/models/shift_summary_spec.rb.
Waterfox
Logistics coordinators pay attention to the short term and long term health of their schedules. In the short term, they look at what shifts need coverage in the next week. In the long term, they look at what shifts need a recurring volunteer and the volunteers that have picked it up in the past. In Rootable, over time, as the data model changed, the shift list page became useless. Clicking on a row on the shift list takes you to the most recent occurrence which is already information we can see on the log.
This makes it difficult to discern which shifts need a recurring volunteer. Its time consuming because you have to check week by week by opening individual tabs for each week. So we want a new shift page that is more helpful.
To figure out what shifts to show, we need to find shifts that are still happening. I created a `shift_summaries` view that tries to pick an the best event for this shift.
A [CTE](https://www.postgresql.org/docs/current/queries-with.html) marks each shift `recurring` or not, and each event in a shift as `recurring` or `remaining`. `events.recurring` is just "are there recurrence options present". `events.remaining` tries to figure out based on `starts_at`, the recurrence options' `UNTIL` and `COUNT`.
Then in the main query, it filters out events based on `shifts.recurring`, the `events.recurring`, and if the event (likely) has `events.remaining` occurrences left.
The full details of how are outlined in `db/views/shift_summaries_v01.sql` and `spec/models/shift_summary_spec.rb`.
