You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that when passing a Range with range.exclude_end? == false to the group_by_xxxx methods an extra day is included causing unwanted time periods in the resulting hash.
We supply the range: argument in the first place because we want the hash full of zeroed out time periods in the case of no data instead of the empty hash that is returned when there is no range supplied.
Reproduction:
note: actual model name changed to "comment" in below examples
range=DateTime.now.all_monthComment.group_by_month(:created_at,range: range).count# Comment Count (12.4ms) SELECT COUNT(*) AS "count_all", DATE_TRUNC('month', "comments"."created_at"::timestamptz AT TIME ZONE 'Etc/UTC')::date AS "date_trunc_month_comments_created_at_timestamptz_at_tim" FROM "comments" WHERE ("comments"."created_at" >= '2023-04-01 00:00:00' AND "comments"."created_at" < '2023-05-01 23:59:59.999999') GROUP BY DATE_TRUNC('month', "comments"."created_at"::timestamptz AT TIME ZONE 'Etc/UTC')::date# => {Thu, 01 Dec 2022=>2557, Sun, 01 Jan 2023=>23}
range=DateTime.now.all_dayComment.group_by_day(:created_at,range: range).count# Comment Count (11.2ms) SELECT COUNT(*) AS "count_all", DATE_TRUNC('day', "comments"."created_at"::timestamptz AT TIME ZONE 'Etc/UTC')::date AS "date_trunc_day_comments_created_at_timestamptz_at_time_" FROM "comments" WHERE ("comments"."created_at" >= '2023-04-18 00:00:00' AND "comments"."created_at" < '2023-04-19 23:59:59.999999') GROUP BY DATE_TRUNC('day', "comments"."created_at"::timestamptz AT TIME ZONE 'Etc/UTC')::date# => {Mon, 12 Dec 2022=>133, Tue, 13 Dec 2022=>218}
range=DateTime.now.all_dayComment.group_by_hour(:created_at,range: range).count.count# Comment Count (11.0ms) SELECT COUNT(*) AS "count_all", DATE_TRUNC('hour', "comments"."created_at"::timestamptz AT TIME ZONE 'Etc/UTC') AT TIME ZONE 'Etc/UTC' AS "date_trunc_hour_comments_created_at_timestamptz_at_time" FROM "actual_locations" WHERE ("comments"."created_at" >= '2023-04-18 00:00:00' AND "comments"."created_at" < '2023-04-19 23:59:59.999999') GROUP BY DATE_TRUNC('hour', "comments"."created_at"::timestamptz AT TIME ZONE 'Etc/UTC') AT TIME ZONE 'Etc/UTC'# => 48
The text was updated successfully, but these errors were encountered:
Hello,
It seems that when passing a Range with
range.exclude_end? == false
to the group_by_xxxx methods an extra day is included causing unwanted time periods in the resulting hash.We supply the
range:
argument in the first place because we want the hash full of zeroed out time periods in the case of no data instead of the empty hash that is returned when there is no range supplied.Reproduction:
note: actual model name changed to "comment" in below examples
The text was updated successfully, but these errors were encountered: