diff --git a/app/assets/javascripts/admin/templates/flags.js.handlebars b/app/assets/javascripts/admin/templates/flags.js.handlebars
index 5c1c2a2c2cc..77e830f40cf 100644
--- a/app/assets/javascripts/admin/templates/flags.js.handlebars
+++ b/app/assets/javascripts/admin/templates/flags.js.handlebars
@@ -32,6 +32,11 @@
{{#if flaggedPost.wasEdited}}{{/if}}
{{/if}}
{{/if}}
+ {{#if adminActiveFlagsView}}
+ {{#if flaggedPost.previous_flags_count}}
+ {{flaggedPost.previous_flags_count}}
+ {{/if}}
+ {{/if}}
diff --git a/app/assets/stylesheets/common/admin/admin_base.scss b/app/assets/stylesheets/common/admin/admin_base.scss
index c5ec878ae80..32443973d56 100644
--- a/app/assets/stylesheets/common/admin/admin_base.scss
+++ b/app/assets/stylesheets/common/admin/admin_base.scss
@@ -584,6 +584,7 @@ section.details {
font-size: 13px;
margin: 0 0 5px 0;
}
+ .flagged-posts { background: $danger; }
}
/* Dashboard */
diff --git a/app/assets/stylesheets/common/base/header.scss b/app/assets/stylesheets/common/base/header.scss
index c3342aeb300..182a46632a6 100644
--- a/app/assets/stylesheets/common/base/header.scss
+++ b/app/assets/stylesheets/common/base/header.scss
@@ -131,7 +131,6 @@
.flagged-posts {
background: $danger;
}
-
}
.d-dropdown {
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index ecddbc6db06..45e6cac20ae 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -1533,6 +1533,7 @@ en:
topic_flagged: "This topic has been flagged."
visit_topic: "Visit the topic to take action"
was_edited: "Post was edited after the first flag"
+ previous_flags_count: "This post has already been flagged {{count}} times."
summary:
action_type_3:
diff --git a/lib/flag_query.rb b/lib/flag_query.rb
index 3c0fb507685..d9f61e7fc05 100644
--- a/lib/flag_query.rb
+++ b/lib/flag_query.rb
@@ -26,11 +26,8 @@ module FlagQuery
p.post_number,
p.hidden,
p.deleted_at,
- (SELECT pr.created_at
- FROM post_revisions pr
- WHERE pr.post_id = p.id AND pr.user_id = p.user_id
- ORDER BY created_at DESC
- LIMIT 1) AS last_revised_at
+ (SELECT created_at FROM post_revisions WHERE post_id = p.id AND user_id = p.user_id ORDER BY created_at DESC LIMIT 1) AS last_revised_at,
+ (SELECT COUNT(*) FROM post_actions WHERE (disagreed_at IS NOT NULL OR agreed_at IS NOT NULL OR deferred_at IS NOT NULL) AND post_id = p.id)::int AS previous_flags_count
FROM posts p
WHERE p.id in (:post_ids)").map_exec(OpenStruct, post_ids: post_ids)
|