discourse/app/serializers/reviewable_perform_result_serializer.rb
Robin Ward cbc311e4ed UX: Update the reviewable count before the message bus
In certain edge cases, the message bus won't send the message to the
user about the updated review count and it can go out of sync.

This patch synchronizes the review count every time:

1. The user visits the "Needs Review" page

2. Every time the user performs an action
2019-04-05 10:35:38 -04:00

46 lines
769 B
Ruby

class ReviewablePerformResultSerializer < ApplicationSerializer
attributes(
:success,
:transition_to,
:transition_to_id,
:created_post_id,
:created_post_topic_id,
:remove_reviewable_ids,
:version,
:reviewable_count
)
def success
object.success?
end
def transition_to_id
Reviewable.statuses[transition_to]
end
def version
object.reviewable.version
end
def created_post_id
object.created_post.id
end
def include_created_post_id?
object.created_post.present?
end
def created_post_topic_id
object.created_post_topic.id
end
def include_created_post_topic_id?
object.created_post_topic.present?
end
def reviewable_count
Reviewable.list_for(scope.user).count
end
end