FEATURE: add count of previous flags on the post

This commit is contained in:
Régis Hanol
2014-09-08 17:53:29 +02:00
parent 7d6f3a5089
commit 00bd665c96
5 changed files with 9 additions and 6 deletions

View File

@ -32,6 +32,11 @@
{{#if flaggedPost.wasEdited}}<i class="fa fa-pencil" title="{{i18n admin.flags.was_edited}}"></i>{{/if}} {{#if flaggedPost.wasEdited}}<i class="fa fa-pencil" title="{{i18n admin.flags.was_edited}}"></i>{{/if}}
{{/if}} {{/if}}
{{/if}} {{/if}}
{{#if adminActiveFlagsView}}
{{#if flaggedPost.previous_flags_count}}
<span title="{{i18n admin.flags.previous_flags_count count=flaggedPost.previous_flags_count}}" class="badge-notification flagged-posts">{{flaggedPost.previous_flags_count}}</span>
{{/if}}
{{/if}}
</td> </td>
<td class='excerpt'> <td class='excerpt'>

View File

@ -584,6 +584,7 @@ section.details {
font-size: 13px; font-size: 13px;
margin: 0 0 5px 0; margin: 0 0 5px 0;
} }
.flagged-posts { background: $danger; }
} }
/* Dashboard */ /* Dashboard */

View File

@ -131,7 +131,6 @@
.flagged-posts { .flagged-posts {
background: $danger; background: $danger;
} }
} }
.d-dropdown { .d-dropdown {

View File

@ -1533,6 +1533,7 @@ en:
topic_flagged: "This <strong>topic</strong> has been flagged." topic_flagged: "This <strong>topic</strong> has been flagged."
visit_topic: "Visit the topic to take action" visit_topic: "Visit the topic to take action"
was_edited: "Post was edited after the first flag" was_edited: "Post was edited after the first flag"
previous_flags_count: "This post has already been flagged {{count}} times."
summary: summary:
action_type_3: action_type_3:

View File

@ -26,11 +26,8 @@ module FlagQuery
p.post_number, p.post_number,
p.hidden, p.hidden,
p.deleted_at, p.deleted_at,
(SELECT pr.created_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,
FROM post_revisions pr (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
WHERE pr.post_id = p.id AND pr.user_id = p.user_id
ORDER BY created_at DESC
LIMIT 1) AS last_revised_at
FROM posts p FROM posts p
WHERE p.id in (:post_ids)").map_exec(OpenStruct, post_ids: post_ids) WHERE p.id in (:post_ids)").map_exec(OpenStruct, post_ids: post_ids)