Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2017-08-01 01:09:41 +0300
committerMike Greiling <mike@pixelcog.com>2017-08-01 01:36:47 +0300
commit1b9b6974fdfb49f10dfdd4bddde05aa8399ff9b1 (patch)
treecceecd7680db71a601377966ad2584d52384a132 /lib/gitlab/contributions_calendar.rb
parentcf2d2cd323ad07783a4953144a7abedf37927633 (diff)
fix mysql syntax for date INTERVAL arithmatic
Diffstat (limited to 'lib/gitlab/contributions_calendar.rb')
-rw-r--r--lib/gitlab/contributions_calendar.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/gitlab/contributions_calendar.rb b/lib/gitlab/contributions_calendar.rb
index c1f84d07477..aa261929fa9 100644
--- a/lib/gitlab/contributions_calendar.rb
+++ b/lib/gitlab/contributions_calendar.rb
@@ -69,11 +69,15 @@ 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'"
+ date_interval = if Gitlab::Database.postgresql?
+ "INTERVAL '#{Time.zone.now.utc_offset} seconds'"
+ else
+ "INTERVAL #{Time.zone.now.utc_offset} SECOND"
+ end
Event.reorder(nil)
- .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})")
+ .select(t[:project_id], t[:target_type], t[:action], "date(created_at + #{date_interval}) AS date", 'count(id) as total_amount')
+ .group(t[:project_id], t[:target_type], t[:action], "date(created_at + #{date_interval})")
.where(conditions)
.having(t[:project_id].in(Arel::Nodes::SqlLiteral.new(authed_projects.to_sql)))
end