Adjust flagged posts to use the store

This commit is contained in:
Robin Ward
2017-09-11 16:44:20 -04:00
parent 5fd3b6615b
commit 5cf50f0034
14 changed files with 149 additions and 155 deletions

View File

@ -10,22 +10,40 @@ class Admin::FlagsController < Admin::AdminController
# we may get out of sync, fix it here
PostAction.update_flagged_posts_count
posts, topics, users = FlagQuery.flagged_posts_report(
posts, topics, users, post_actions = FlagQuery.flagged_posts_report(
current_user,
filter: params[:filter],
offset: params[:offset].to_i,
topic_id: params[:topic_id],
per_page: Admin::FlagsController.flags_per_page
per_page: Admin::FlagsController.flags_per_page,
rest_api: params[:rest_api].present?
)
if posts.blank?
render json: { posts: [], topics: [], users: [] }
else
render json: MultiJson.dump(
posts: posts,
topics: serialize_data(topics, FlaggedTopicSerializer),
users: serialize_data(users, FlaggedUserSerializer)
)
if params[:rest_api]
render_json_dump(
{
flagged_posts: posts,
topics: serialize_data(topics, FlaggedTopicSerializer),
users: serialize_data(users, FlaggedUserSerializer),
post_actions: post_actions
},
rest_serializer: true,
meta: {
types: {
disposed_by: 'user'
}
}
)
else
render_json_dump(
posts: posts,
topics: serialize_data(topics, FlaggedTopicSerializer),
users: serialize_data(users, FlaggedUserSerializer)
)
end
end
end