diff --git a/app/models/reports/post_edits.rb b/app/models/reports/post_edits.rb index 43c039cc0c7..4d24f782cee 100644 --- a/app/models/reports/post_edits.rb +++ b/app/models/reports/post_edits.rb @@ -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| diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb index 21418aff3df..f2e78a2d62b 100644 --- a/spec/models/report_spec.rb +++ b/spec/models/report_spec.rb @@ -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