Skip to content

Commit

Permalink
Merge pull request #69 from mustachebash/bugfix/timezones
Browse files Browse the repository at this point in the history
timezones are hard, especially when the operate differently between a column value and now()
  • Loading branch information
jfurfaro authored Jan 21, 2024
2 parents 1fe18d4 + bc313b6 commit 123cf3a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/services/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ module.exports = {
count(g.id) FILTER (WHERE g.status <> 'archived') as total_guests,
count(g.id) FILTER (WHERE g.created_reason = 'comp') as total_comped_guests,
count(g.id) FILTER (WHERE g.admission_tier = 'vip') as total_vip_guests,
count(g.id) FILTER (WHERE (g.created AT TIME ZONE 'UTC' AT TIME ZONE 'America/Los_Angeles')::date = (now() AT TIME ZONE 'UTC' AT TIME ZONE 'America/Los_Angeles')::date) as guests_today,
count(g.id) FILTER (WHERE (g.created AT TIME ZONE 'UTC' AT TIME ZONE 'America/Los_Angeles')::date = (now() AT TIME ZONE 'America/Los_Angeles')::date) as guests_today,
count(g.id) FILTER (WHERE g.status = 'checked_in') as checked_in
FROM events as e
LEFT JOIN guests as g
Expand Down Expand Up @@ -262,7 +262,7 @@ module.exports = {
ON i.order_id = o.id
LEFT JOIN products p
ON p.id = i.product_id
WHERE (o.created AT TIME ZONE 'UTC' AT TIME ZONE 'America/Los_Angeles')::date = (now() AT TIME ZONE 'UTC' AT TIME ZONE 'America/Los_Angeles')::date
WHERE (o.created AT TIME ZONE 'UTC' AT TIME ZONE 'America/Los_Angeles')::date = (now() AT TIME ZONE 'America/Los_Angeles')::date
AND p.event_id = ${id}
GROUP BY p.event_id
)
Expand Down

0 comments on commit 123cf3a

Please sign in to comment.