Watch
5
11
Fork
You've already forked tomato
1

Add a shift filter #115

Merged
edwardloveall merged 2 commits from el-shift-filter into main 2026年03月17日 14:03:48 +01:00

Similar to the shift occurrence filter, this allows admins to filter shifts on the shift index page. Since we're filtering shifts with their representative events (ShiftSummary), it mostly filters things on events:

  • recurring, non-recurring, recurring-agnostic
  • has a specific site
  • has a specific user
  • has no users
  • happens on a particular weekday
  • time of day overlaps with a time range

Technical notes

Time range and weekday filter were tricky because they need to take into account
the organization's time zone. We don't store a time zone on the starts_at
timestamp (this is a rails default). When Rails creates an event, starts_at is
converted from the org's time zone to UTC and stored in postgres. When we
filter, first we need to tell postgres that the time is in UTC. Then, we tell it
convert the timestamp to the org's time zone, and finally convert it to
postgres' time type, or day-of-week (dow) for comparison.

This also required joining the event to the organization. Events have a
polymorphic association to the org which rails does not allow you to join on, so
I also added the organization relationship explicitly.

  • user input: 2026年01月01日 10:00AM MST
  • postgres stored: 2026年01月01日 17:00 (no time zone)
  • utc zone convert: 2026年01月01日 17:00 UTC
  • org zone convert: 2026年01月01日 10:00 MST
  • time convert: 10:00
Similar to the shift occurrence filter, this allows admins to filter shifts on the shift index page. Since we're filtering shifts with their representative events (ShiftSummary), it mostly filters things on events: - recurring, non-recurring, recurring-agnostic - has a specific site - has a specific user - has no users - happens on a particular weekday - time of day overlaps with a time range <video src="/attachments/42c51a55-8007-423a-9eff-c5d89551e84a" title="Waterfox" controls></video> ## Technical notes Time range and weekday filter were tricky because they need to take into account the organization's time zone. We don't store a time zone on the `starts_at` timestamp (this is a rails default). When Rails creates an event, `starts_at` is converted from the org's time zone to UTC and stored in postgres. When we filter, first we need to tell postgres that the time is in UTC. Then, we tell it convert the timestamp to the org's time zone, and finally convert it to postgres' `time` type, or day-of-week (`dow`) for comparison. This also required joining the event to the organization. Events have a polymorphic association to the org which rails does not allow you to join on, so I also added the organization relationship explicitly. - user input: 2026年01月01日 10:00AM MST - postgres stored: 2026年01月01日 17:00 (no time zone) - utc zone convert: 2026年01月01日 17:00 UTC - org zone convert: 2026年01月01日 10:00 MST - time convert: 10:00
edwardloveall force-pushed el-shift-filter from 071c5ad586
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
to 4ce2db9624
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
2026年03月11日 17:04:40 +01:00
Compare
edwardloveall force-pushed el-shift-filter from 4ce2db9624
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
to 2d9bd6aac2
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
2026年03月11日 21:20:02 +01:00
Compare
edwardloveall force-pushed el-shift-filter from 2d9bd6aac2
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
to 4fe73c8002
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
2026年03月12日 17:33:18 +01:00
Compare
edwardloveall force-pushed el-shift-filter from 4fe73c8002
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
to 3b0e0e754f
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
2026年03月12日 18:34:30 +01:00
Compare
edwardloveall changed target branch from el-shift-show to main 2026年03月17日 14:03:12 +01:00
edwardloveall deleted branch el-shift-filter 2026年03月17日 14:03:50 +01:00
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
2 participants
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!115
Reference in a new issue
rootable/tomato
No description provided.
Delete branch "el-shift-filter"

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?