Replace contributions calendar timezone payload with dates
This commit is contained in:
parent
1c2aa4f879
commit
a147b43dcc
|
@ -30,6 +30,7 @@ v 8.12.0 (unreleased)
|
||||||
- Fix file permissions change when updating a file on the Gitlab UI !5979
|
- Fix file permissions change when updating a file on the Gitlab UI !5979
|
||||||
- Change merge_error column from string to text type
|
- Change merge_error column from string to text type
|
||||||
- Reduce contributions calendar data payload (ClemMakesApps)
|
- Reduce contributions calendar data payload (ClemMakesApps)
|
||||||
|
- Replace contributions calendar timezone payload with dates (ClemMakesApps)
|
||||||
- Add `web_url` field to issue, merge request, and snippet API objects (Ben Boeckel)
|
- Add `web_url` field to issue, merge request, and snippet API objects (Ben Boeckel)
|
||||||
- Enable pipeline events by default !6278
|
- Enable pipeline events by default !6278
|
||||||
- Move parsing of sidekiq ps into helper !6245 (pascalbetz)
|
- Move parsing of sidekiq ps into helper !6245 (pascalbetz)
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
date.setDate(date.getDate() + i);
|
date.setDate(date.getDate() + i);
|
||||||
|
|
||||||
var day = date.getDay();
|
var day = date.getDay();
|
||||||
var count = timestamps[date.getTime() * 0.001];
|
var count = timestamps[dateFormat(date, 'yyyy-mm-dd')];
|
||||||
|
|
||||||
// Create a new group array if this is the first day of the week
|
// Create a new group array if this is the first day of the week
|
||||||
// or if is first object
|
// or if is first object
|
||||||
|
|
|
@ -73,7 +73,7 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
def calendar
|
def calendar
|
||||||
calendar = contributions_calendar
|
calendar = contributions_calendar
|
||||||
@timestamps = calendar.timestamps
|
@activity_dates = calendar.activity_dates
|
||||||
|
|
||||||
render 'calendar', layout: false
|
render 'calendar', layout: false
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,6 @@
|
||||||
Summary of issues, merge requests, and push events
|
Summary of issues, merge requests, and push events
|
||||||
:javascript
|
:javascript
|
||||||
new Calendar(
|
new Calendar(
|
||||||
#{@timestamps.to_json},
|
#{@activity_dates.to_json},
|
||||||
'#{user_calendar_activities_path}'
|
'#{user_calendar_activities_path}'
|
||||||
);
|
);
|
|
@ -1,16 +1,16 @@
|
||||||
module Gitlab
|
module Gitlab
|
||||||
class ContributionsCalendar
|
class ContributionsCalendar
|
||||||
attr_reader :timestamps, :projects, :user
|
attr_reader :activity_dates, :projects, :user
|
||||||
|
|
||||||
def initialize(projects, user)
|
def initialize(projects, user)
|
||||||
@projects = projects
|
@projects = projects
|
||||||
@user = user
|
@user = user
|
||||||
end
|
end
|
||||||
|
|
||||||
def timestamps
|
def activity_dates
|
||||||
return @timestamps if @timestamps.present?
|
return @activity_dates if @activity_dates.present?
|
||||||
|
|
||||||
@timestamps = {}
|
@activity_dates = {}
|
||||||
date_from = 1.year.ago
|
date_from = 1.year.ago
|
||||||
|
|
||||||
events = Event.reorder(nil).contributions.where(author_id: user.id).
|
events = Event.reorder(nil).contributions.where(author_id: user.id).
|
||||||
|
@ -19,18 +19,17 @@ module Gitlab
|
||||||
select('date(created_at) as date, count(id) as total_amount').
|
select('date(created_at) as date, count(id) as total_amount').
|
||||||
map(&:attributes)
|
map(&:attributes)
|
||||||
|
|
||||||
dates = (1.year.ago.to_date..Date.today).to_a
|
activity_dates = (1.year.ago.to_date..Date.today).to_a
|
||||||
|
|
||||||
dates.each do |date|
|
activity_dates.each do |date|
|
||||||
date_id = date.to_time.to_i.to_s
|
|
||||||
day_events = events.find { |day_events| day_events["date"] == date }
|
day_events = events.find { |day_events| day_events["date"] == date }
|
||||||
|
|
||||||
if day_events
|
if day_events
|
||||||
@timestamps[date_id] = day_events["total_amount"]
|
@activity_dates[date] = day_events["total_amount"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@timestamps
|
@activity_dates
|
||||||
end
|
end
|
||||||
|
|
||||||
def events_by_date(date)
|
def events_by_date(date)
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
feature 'Contributions Calendar', js: true, feature: true do
|
||||||
|
include WaitForAjax
|
||||||
|
|
||||||
|
let(:contributed_project) { create(:project, :public) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
login_as :user
|
||||||
|
|
||||||
|
issue_params = { title: 'Bug in old browser' }
|
||||||
|
Issues::CreateService.new(contributed_project, @user, issue_params).execute
|
||||||
|
|
||||||
|
# Push code contribution
|
||||||
|
push_params = {
|
||||||
|
project: contributed_project,
|
||||||
|
action: Event::PUSHED,
|
||||||
|
author_id: @user.id,
|
||||||
|
data: { commit_count: 3 }
|
||||||
|
}
|
||||||
|
|
||||||
|
Event.create(push_params)
|
||||||
|
|
||||||
|
visit @user.username
|
||||||
|
wait_for_ajax
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'displays calendar', js: true do
|
||||||
|
expect(page).to have_css('.js-contrib-calendar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'displays calendar activity log', js: true do
|
||||||
|
expect(find('.content_list .event-note')).to have_content "Bug in old browser"
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'displays calendar activity square color', js: true do
|
||||||
|
expect(page).to have_selector('.user-contrib-cell[fill=\'#acd5f2\']', count: 1)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue