5
11
Fork
You've already forked tomato
1

New shift index #108

Manually merged
edwardloveall merged 2 commits from el-new-shift-index into main 2026年03月05日 21:59:20 +01:00

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`. ![Waterfox](/attachments/9203e501-06cb-4116-8c5c-afeb95c5429a)
.prettierrc.json Outdated
@ -0,0 +2,4 @@
"overrides":[
"files": ["config/locales/en.yml"],
"options": {
"jsxSingleQuote": true
Author
Owner
Copy link

Prettier and i18n-tasks normalize disagree single or double quotes. I opted to use the i18n-tasks default because prettier was easier to configure.

Prettier and `i18n-tasks normalize` [disagree](https://github.com/glebm/i18n-tasks/pull/704) single or double quotes. I opted to use the i18n-tasks default because prettier was easier to configure.
@ -12,0 +8,4 @@
.where(ownable: @organization)
.order(:starts_at)
.group_by { it.starts_at.wday }
# TODO: should this sort with today first, then the days in order after?
Author
Owner
Copy link

We're going to put this up on our staging server and ask, so this is fine for now.

We're going to put this up on our staging server and ask, so this is fine for now.
@ -0,0 +13,4 @@
/*
h/t to Eric Bailey's article on Accessible faux-nested interactive controls
https://piccalil.li/blog/accessible-faux-nested-interactive-controls/
Author
Owner
Copy link

Can't recommend this article enough if you ever want to have an element that is a link with other clickable stuff inside that element.

Can't recommend this article enough if you ever want to have an element that is a link with other clickable stuff inside that element.
edwardloveall force-pushed el-new-shift-index from b678554129
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
to 4b20f91b8e 2026年03月04日 22:47:16 +01:00
Compare
edwardloveall force-pushed el-new-shift-index from 3406712ba8 to d3ee3831fa
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
2026年03月05日 16:28:34 +01:00
Compare
edwardloveall force-pushed el-new-shift-index from d3ee3831fa
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
to b776cbb133
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
2026年03月05日 16:29:55 +01:00
Compare
edwardloveall changed target branch from el-remove-active-snapshot to main 2026年03月05日 17:13:50 +01:00
edwardloveall force-pushed el-new-shift-index from b776cbb133
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
to 8f5f99cd9e
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
2026年03月05日 17:21:32 +01:00
Compare
edwardloveall force-pushed el-new-shift-index from 8f5f99cd9e
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
to 6a2f0be9f1
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
2026年03月05日 18:26:38 +01:00
Compare
edwardloveall force-pushed el-new-shift-index from 6a2f0be9f1
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
to 8cd1b49751
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
2026年03月05日 21:59:19 +01:00
Compare
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rootable/tomato!108
Reference in a new issue
rootable/tomato
No description provided.
Delete branch "el-new-shift-index"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?