Commit 6328c790 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu Committed by Mayra Cabrera

Include DiffNotes and DiscussionNotes in calendar

parent 2cb2e671
......@@ -130,10 +130,11 @@ class Event < ApplicationRecord
# Update Gitlab::ContributionsCalendar#activity_dates if this changes
def contributions
where("action = ? OR (target_type IN (?) AND action IN (?)) OR (target_type = ? AND action = ?)",
actions[:pushed],
%w(MergeRequest Issue), [actions[:created], actions[:closed], actions[:merged]],
"Note", actions[:commented])
where(
'action IN (?) OR (target_type IN (?) AND action IN (?))',
[actions[:pushed], actions[:commented]],
%w(MergeRequest Issue), [actions[:created], actions[:closed], actions[:merged]]
)
end
def limit_recent(limit = 20, offset = nil)
......
......@@ -29,13 +29,13 @@ module Gitlab
# project_features for the (currently) 3 different contribution types
date_from = @contributor_time_instance.now.years_ago(1)
repo_events = event_created_at(date_from, :repository)
.where(action: :pushed, target_type: nil)
.where(action: :pushed)
issue_events = event_created_at(date_from, :issues)
.where(action: [:created, :closed], target_type: "Issue")
mr_events = event_created_at(date_from, :merge_requests)
.where(action: [:merged, :created, :closed], target_type: "MergeRequest")
note_events = event_created_at(date_from, :merge_requests)
.where(action: :commented, target_type: "Note")
.where(action: :commented)
events = Event
.select("date(created_at + #{date_interval}) AS date", 'COUNT(*) AS num_events')
......
......@@ -50,7 +50,8 @@ RSpec.describe Gitlab::ContributionsCalendar do
Event.create!(
project: project,
action: action,
target: @targets[project],
target_type: @targets[project].class.name,
target_id: @targets[project].id,
author: contributor,
created_at: DateTime.new(day.year, day.month, day.day, hour)
)
......@@ -169,6 +170,12 @@ RSpec.describe Gitlab::ContributionsCalendar do
expect(calendar(contributor).events_by_date(today)).to contain_exactly(e1, e2, e3)
end
it "includes diff notes on merge request" do
e1 = create_event(public_project, today, 0, :commented, :diff_note_on_merge_request)
expect(calendar.events_by_date(today)).to contain_exactly(e1)
end
context 'when the user cannot read cross project' do
before do
allow(Ability).to receive(:allowed?).and_call_original
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment