Commit d1d17335 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'fix-diff-notes-in-contribution-calendar-and-list' into 'master'

Include DiffNotes and DiscussionNotes in calendar

See merge request gitlab-org/gitlab!75830
parents daab5c93 6328c790
...@@ -130,10 +130,11 @@ class Event < ApplicationRecord ...@@ -130,10 +130,11 @@ class Event < ApplicationRecord
# Update Gitlab::ContributionsCalendar#activity_dates if this changes # Update Gitlab::ContributionsCalendar#activity_dates if this changes
def contributions def contributions
where("action = ? OR (target_type IN (?) AND action IN (?)) OR (target_type = ? AND action = ?)", where(
actions[:pushed], 'action IN (?) OR (target_type IN (?) AND action IN (?))',
%w(MergeRequest Issue), [actions[:created], actions[:closed], actions[:merged]], [actions[:pushed], actions[:commented]],
"Note", actions[:commented]) %w(MergeRequest Issue), [actions[:created], actions[:closed], actions[:merged]]
)
end end
def limit_recent(limit = 20, offset = nil) def limit_recent(limit = 20, offset = nil)
......
...@@ -30,13 +30,13 @@ module Gitlab ...@@ -30,13 +30,13 @@ module Gitlab
# project_features for the (currently) 3 different contribution types # project_features for the (currently) 3 different contribution types
date_from = @contributor_time_instance.now.years_ago(1) date_from = @contributor_time_instance.now.years_ago(1)
repo_events = event_created_at(date_from, :repository) 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) issue_events = event_created_at(date_from, :issues)
.where(action: [:created, :closed], target_type: "Issue") .where(action: [:created, :closed], target_type: "Issue")
mr_events = event_created_at(date_from, :merge_requests) mr_events = event_created_at(date_from, :merge_requests)
.where(action: [:merged, :created, :closed], target_type: "MergeRequest") .where(action: [:merged, :created, :closed], target_type: "MergeRequest")
note_events = event_created_at(date_from, :merge_requests) note_events = event_created_at(date_from, :merge_requests)
.where(action: :commented, target_type: "Note") .where(action: :commented)
events = Event events = Event
.select("date(created_at + #{date_interval}) AS date", 'COUNT(*) AS num_events') .select("date(created_at + #{date_interval}) AS date", 'COUNT(*) AS num_events')
......
...@@ -50,7 +50,8 @@ RSpec.describe Gitlab::ContributionsCalendar do ...@@ -50,7 +50,8 @@ RSpec.describe Gitlab::ContributionsCalendar do
Event.create!( Event.create!(
project: project, project: project,
action: action, action: action,
target: @targets[project], target_type: @targets[project].class.name,
target_id: @targets[project].id,
author: contributor, author: contributor,
created_at: DateTime.new(day.year, day.month, day.day, hour) created_at: DateTime.new(day.year, day.month, day.day, hour)
) )
...@@ -189,6 +190,12 @@ RSpec.describe Gitlab::ContributionsCalendar do ...@@ -189,6 +190,12 @@ RSpec.describe Gitlab::ContributionsCalendar do
expect(calendar(contributor).events_by_date(today)).to contain_exactly(e1, e2, e3) expect(calendar(contributor).events_by_date(today)).to contain_exactly(e1, e2, e3)
end 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 context 'when the user cannot read cross project' do
before do before do
allow(Ability).to receive(:allowed?).and_call_original 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