Skip to content

Commit

Permalink
Use Sunday as the start of the week on report
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospri committed Dec 10, 2024
1 parent a4865c4 commit 7bf014e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ AS $$
ELSE INTERVAL '6 months'
END
))::DATE
WHEN resolution = 'week' THEN
-- -1 day to start weeks on Sunday
(DATE_TRUNC('week', date) - '1 day'::interval)::date
ELSE DATE_TRUNC(resolution, date)::date
END
$$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ CREATE MATERIALIZED VIEW report.annotation_counts AS (
group_id,
user_id,
-- Cast to a date as it's 4 bytes instead of 8
DATE_TRUNC('week', created)::DATE AS created_week,
-- -1 day to start weeks on Sunday
(DATE_TRUNC('week', created) - '1 day'::interval)::date AS created_week,
CASE
WHEN ARRAY_LENGTH(parent_uuids, 1) IS NOT NULL
THEN 'reply'::report.annotation_sub_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ CREATE MATERIALIZED VIEW report.authority_activity AS (
SELECT
users.id AS user_id,
authorities.id AS authority_id,
DATE_TRUNC('week', users.registered_date)::DATE AS registered_week
-- -1 day to start weeks on Sunday
(DATE_TRUNC('week', users.registered_date) - '1 day'::interval)::date AS registered_date,
FROM "user" AS users
JOIN report.authorities ON
authorities.authority = users.authority
Expand Down

0 comments on commit 7bf014e

Please sign in to comment.