diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-08-07 11:43:18 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-08-07 11:43:18 +0100 |
commit | fecb1a2f3c77205a72eeff1a3501629d2d1811d8 (patch) | |
tree | db6fe0c250f3238b011fe47afca301e77e529a6c /lib | |
parent | 7065bb3ef31fe04bea39aa07d620552eaaa26aba (diff) | |
parent | 03b816f3e845c9b25d3588336fc1616238465deb (diff) | |
download | gitlab-ce-fecb1a2f3c77205a72eeff1a3501629d2d1811d8.tar.gz |
Merge branch 'master' into issue-discussions-refactor
* master: (21 commits)
Fix issues with pdf-js dependencies
fix missing changelog entries for security release on 2017-01-23
Update top bar issues icon
Fix order of CI lint ace editor loading
Fix spec
Fix spec
Fix spec
Add changelog
fix
Add a spec for concurrent process
Add changelog
essential
add CHANGELOG.md for !13208
adjust user contribution calendar time formatting
fix rubocop violations 👮
fix mysql syntax for date INTERVAL arithmatic
add tests for proper timezone date grouping within ContributionsCalendar
adjust timezone for date grouping in contributions calendar
use timezone-aware Date.current instead of Date.today in ContributionsCalendar class
display system timezone underneath activity calendar
...
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/contributions_calendar.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/gitlab/contributions_calendar.rb b/lib/gitlab/contributions_calendar.rb index bf557103cfd..0735243e021 100644 --- a/lib/gitlab/contributions_calendar.rb +++ b/lib/gitlab/contributions_calendar.rb @@ -48,7 +48,7 @@ module Gitlab end def starting_month - Date.today.month + Date.current.month end private @@ -66,12 +66,18 @@ module Gitlab .select(:id) conditions = t[:created_at].gteq(date_from.beginning_of_day) - .and(t[:created_at].lteq(Date.today.end_of_day)) + .and(t[:created_at].lteq(Date.current.end_of_day)) .and(t[:author_id].eq(contributor.id)) + 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) 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 + #{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 |