diff options
author | Mike Greiling <mike@pixelcog.com> | 2017-07-29 01:50:17 -0500 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2017-07-29 01:50:17 -0500 |
commit | d1f5e81e8b80d8c322bb47c70728a2536d4708cc (patch) | |
tree | fa3bed918ec1e96acf0660290f983af864e304bd | |
parent | be77d76e7338ee40ecdad54cc40b3b5afa55f2b1 (diff) | |
download | gitlab-ce-d1f5e81e8b80d8c322bb47c70728a2536d4708cc.tar.gz |
adjust timezone for date grouping in contributions calendar
-rw-r--r-- | lib/gitlab/contributions_calendar.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/gitlab/contributions_calendar.rb b/lib/gitlab/contributions_calendar.rb index b3d84e4b6d5..c1f84d07477 100644 --- a/lib/gitlab/contributions_calendar.rb +++ b/lib/gitlab/contributions_calendar.rb @@ -69,9 +69,11 @@ module Gitlab .and(t[:created_at].lteq(Date.current.end_of_day)) .and(t[:author_id].eq(contributor.id)) + timezone_adjust = "INTERVAL '#{Time.zone.now.utc_offset} SECONDS'" + Event.reorder(nil) - .select(t[:project_id], t[:target_type], t[:action], 'date(created_at) AS date', 'count(id) as total_amount') - .group(t[:project_id], t[:target_type], t[:action], 'date(created_at)') + .select(t[:project_id], t[:target_type], t[:action], "date(created_at + #{timezone_adjust}) AS date", 'count(id) as total_amount') + .group(t[:project_id], t[:target_type], t[:action], "date(created_at + #{timezone_adjust})") .where(conditions) .having(t[:project_id].in(Arel::Nodes::SqlLiteral.new(authed_projects.to_sql))) end |