FIX: Store Reviewable's force_review as a boolean. (#11219)

* FIX: Store Reviewable's force_review as a boolean.

Using the `force_review` flag raises the score to hit the minimum visibility threshold. This strategy turned out to be ineffective on sites with a high number of flags, where these values could rapidly fluctuate.

This change adds a `force_review` column on the reviewables table and modifies the `Reviewable#list_for` method to show these items when passing the `status: :pending` option, even if the score is not high enough. ReviewableQueuedPosts and ReviewableUsers are always created using this option.
This commit is contained in:
Roman Rizzi
2020-11-13 08:19:01 -03:00
committed by GitHub
parent bd0b558a89
commit f2bef7ea8f
5 changed files with 15 additions and 21 deletions

View File

@@ -363,8 +363,6 @@ describe NewPostManager do
end
it "calls custom enqueuing handlers" do
Reviewable.set_priorities(high: 20.5)
SiteSetting.reviewable_default_visibility = 'high'
SiteSetting.tagging_enabled = true
SiteSetting.min_trust_to_create_tag = 0
SiteSetting.min_trust_level_to_tag_topics = 0
@@ -384,7 +382,7 @@ describe NewPostManager do
expect(reviewable).to be_present
expect(reviewable.payload['title']).to eq('this is the title of the queued post')
expect(reviewable.reviewable_scores).to be_present
expect(reviewable.score).to eq(20.5)
expect(reviewable.force_review).to eq(true)
expect(reviewable.reviewable_by_moderator?).to eq(true)
expect(reviewable.category).to be_present
expect(reviewable.payload['tags']).to eq(['hello', 'world'])

View File

@@ -120,15 +120,12 @@ describe PostActionCreator do
expect(post.hidden?).to eq(false)
end
it 'forces the review to surpass the minimum priority threshold' do
Reviewable.set_priorities(high: 40.0)
SiteSetting.reviewable_default_visibility = 'high'
it 'sets the force_review field' do
result = PostActionCreator.create(user, post, :spam)
reviewable = result.reviewable
reviewable_score = reviewable.reviewable_scores.find_by(user: user)
expect(reviewable_score.score).to eq(Reviewable.min_score_for_priority)
expect(reviewable.force_review).to eq(true)
end
end

View File

@@ -180,8 +180,8 @@ RSpec.describe Reviewable, type: :model do
before do
SiteSetting.reviewable_default_visibility = :high
Reviewable.set_priorities(high: 10)
@queued_post = Fabricate(:reviewable_queued_post, score: 0, target: post)
@queued_user = Fabricate(:reviewable_user, score: 0)
@queued_post = Fabricate(:reviewable_queued_post, score: 0, target: post, force_review: true)
@queued_user = Fabricate(:reviewable_user, score: 0, force_review: true)
end
it 'includes queued posts when searching for pending reviewables' do