From d1f5e81e8b80d8c322bb47c70728a2536d4708cc Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Sat, 29 Jul 2017 01:50:17 -0500 Subject: adjust timezone for date grouping in contributions calendar --- lib/gitlab/contributions_calendar.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/gitlab/contributions_calendar.rb') 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 -- cgit v1.2.1