FIX: Do not show self edits in Post Edits report. (#7510)

This commit is contained in:
Bianca Nenciu 2019-05-09 20:39:17 +03:00 committed by GitHub
parent ea3004ef11
commit 8dfb15a2e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -56,7 +56,7 @@ Report.add_report('post_edits') do |report|
AND pr.created_at >= '#{report.start_date}'
AND pr.created_at <= '#{report.end_date}'
ORDER BY pr.created_at DESC
LIMIT 20
LIMIT #{report.limit || 20}
)
SELECT pr.editor_id,
pr.editor_username,
@ -83,9 +83,12 @@ Report.add_report('post_edits') do |report|
sql += <<~SQL
JOIN topics t
ON t.id = p.topic_id
WHERE t.category_id = ? OR t.category_id IN (SELECT id FROM categories WHERE categories.parent_category_id = ?)
WHERE p.user_id != editor_id AND t.category_id = ? OR t.category_id IN (SELECT id FROM categories WHERE categories.parent_category_id = ?)
SQL
else
sql += "WHERE p.user_id != editor_id"
end
result = category_filter ? DB.query(sql, category_filter, category_filter) : DB.query(sql)
result.each do |r|

View File

@ -544,6 +544,7 @@ describe Report do
before do
freeze_time
post.revise(post.user, { raw: 'updated body by author', edit_reason: 'not cool' }, force_new_version: true)
post.revise(editor, raw: 'updated body', edit_reason: 'not cool')
end