Commit 706737a0 authored by Yorick Peterse's avatar Yorick Peterse

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 7887a3da
...@@ -380,6 +380,7 @@ class Project < ActiveRecord::Base ...@@ -380,6 +380,7 @@ class Project < ActiveRecord::Base
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)}
AND system IS FALSE
GROUP BY project_id GROUP BY project_id
) join_note_counts ON projects.id = join_note_counts.project_id" ) join_note_counts ON projects.id = join_note_counts.project_id"
......
...@@ -826,6 +826,14 @@ describe Project, models: true do ...@@ -826,6 +826,14 @@ describe Project, models: true do
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)
end
expect(described_class.trending.to_a).to eq([project1, project2])
end
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