This instance will be upgraded to Heptapod 0.31.0rc on 2022-05-19 at 11:00 UTC+2 (a few minutes of down time)

Unverified Commit 706737a0 authored by Yorick Peterse's avatar Yorick Peterse
Browse files

Exclude system notes from Project.trending

Having many system notes isn't really an indication of a project being
trending. Including these notes would lead to projects with lots of
commit cross references (for example) showing up in the trending
projects list.
parent ea5c71966b9c
...@@ -380,6 +380,7 @@ def trending(since = 1.month.ago) ...@@ -380,6 +380,7 @@ def trending(since = 1.month.ago)
SELECT project_id, COUNT(*) AS amount SELECT project_id, COUNT(*) AS amount
FROM notes FROM notes
WHERE created_at >= #{sanitize(since)} WHERE created_at >= #{sanitize(since)}
GROUP BY project_id GROUP BY project_id
) join_note_counts ON = join_note_counts.project_id" ) join_note_counts ON = join_note_counts.project_id"
...@@ -826,6 +826,14 @@ def create_pipeline ...@@ -826,6 +826,14 @@ def create_pipeline
expect(subject).to eq([project2, project1]) expect(subject).to eq([project2, project1])
end end
end end
it 'does not take system notes into account' do
10.times do
create(:note_on_commit, project: project2, system: true)
expect(described_class.trending.to_a).to eq([project1, project2])
end end
describe '.visible_to_user' do describe '.visible_to_user' do
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