fix mysql syntax for date INTERVAL arithmatic
This commit is contained in:
parent
cf2d2cd323
commit
1b9b6974fd
1 changed files with 7 additions and 3 deletions
|
@ -69,11 +69,15 @@ module Gitlab
|
||||||
.and(t[:created_at].lteq(Date.current.end_of_day))
|
.and(t[:created_at].lteq(Date.current.end_of_day))
|
||||||
.and(t[:author_id].eq(contributor.id))
|
.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)
|
Event.reorder(nil)
|
||||||
.select(t[:project_id], t[:target_type], t[:action], "date(created_at + #{timezone_adjust}) AS date", 'count(id) as total_amount')
|
.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 + #{timezone_adjust})")
|
.group(t[:project_id], t[:target_type], t[:action], "date(created_at + #{date_interval})")
|
||||||
.where(conditions)
|
.where(conditions)
|
||||||
.having(t[:project_id].in(Arel::Nodes::SqlLiteral.new(authed_projects.to_sql)))
|
.having(t[:project_id].in(Arel::Nodes::SqlLiteral.new(authed_projects.to_sql)))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue