mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 02:19:27 +08:00
FEATURE: add caps to trust level 3 requirements for posts read and topics viewed, configurable in settings
This commit is contained in:
parent
cf97efb643
commit
a4cd068481
|
@ -95,7 +95,10 @@ class TrustLevel3Requirements
|
|||
end
|
||||
|
||||
def min_topics_viewed
|
||||
(TrustLevel3Requirements.num_topics_in_time_period.to_i * (SiteSetting.tl3_requires_topics_viewed.to_f / 100.0)).round
|
||||
[
|
||||
(TrustLevel3Requirements.num_topics_in_time_period.to_i * (SiteSetting.tl3_requires_topics_viewed.to_f / 100.0)).round,
|
||||
SiteSetting.tl3_requires_topics_viewed_cap
|
||||
].min
|
||||
end
|
||||
|
||||
def posts_read
|
||||
|
@ -103,7 +106,10 @@ class TrustLevel3Requirements
|
|||
end
|
||||
|
||||
def min_posts_read
|
||||
(TrustLevel3Requirements.num_posts_in_time_period.to_i * (SiteSetting.tl3_requires_posts_read.to_f / 100.0)).round
|
||||
[
|
||||
(TrustLevel3Requirements.num_posts_in_time_period.to_i * (SiteSetting.tl3_requires_posts_read.to_f / 100.0)).round,
|
||||
SiteSetting.tl3_requires_posts_read_cap
|
||||
].min
|
||||
end
|
||||
|
||||
def topics_viewed_all_time
|
||||
|
|
|
@ -1068,7 +1068,9 @@ en:
|
|||
tl3_requires_days_visited: "Minimum number of days that a user needs to have visited the site in the last (tl3 time period) days to qualify for promotion to trust level 3. Set higher than tl3 time period to disable promotions to tl3. (0 or higher)"
|
||||
tl3_requires_topics_replied_to: "Minimum number of topics a user needs to have replied to in the last (tl3 time period) days to qualify for promotion to trust level 3. (0 or higher)"
|
||||
tl3_requires_topics_viewed: "The percentage of topics created in the last (tl3 time period) days that a user needs to have viewed to qualify for promotion to trust level 3. (0 to 100)"
|
||||
tl3_requires_topics_viewed_cap: "The maximum required number of topics viewed in the last (tl3 time period) days."
|
||||
tl3_requires_posts_read: "The percentage of posts created in the last (tl3 time period) days that a user needs to have viewed to qualify for promotion to trust level 3. (0 to 100)"
|
||||
tl3_requires_posts_read_cap: "The maximum required number of posts read in the last (tl3 time period) days."
|
||||
tl3_requires_topics_viewed_all_time: "The minimum total number of topics a user must have viewed to qualify for trust level 3."
|
||||
tl3_requires_posts_read_all_time: "The minimum total number of posts a user must have read to qualify for trust level 3."
|
||||
tl3_requires_max_flagged: "User must not have had more than x posts flagged by x different users in the last (tl3 time period) days to qualify for promotion to trust level 3, where x is this setting's value. (0 or higher)"
|
||||
|
|
|
@ -708,10 +708,16 @@ trust:
|
|||
default: 25
|
||||
min: 0
|
||||
max: 100
|
||||
tl3_requires_topics_viewed_cap:
|
||||
default: 500
|
||||
min: 0
|
||||
tl3_requires_posts_read:
|
||||
default: 25
|
||||
min: 0
|
||||
max: 100
|
||||
tl3_requires_posts_read_cap:
|
||||
default: 20000
|
||||
min: 0
|
||||
tl3_requires_topics_viewed_all_time:
|
||||
default: 200
|
||||
min: 0
|
||||
|
|
|
@ -35,12 +35,26 @@ describe TrustLevel3Requirements do
|
|||
expect(tl3_requirements.min_topics_viewed).to eq(23)
|
||||
end
|
||||
|
||||
it "min_topics_viewed is capped" do
|
||||
SiteSetting.tl3_requires_topics_viewed = 75
|
||||
described_class.stubs(:num_topics_in_time_period).returns(31)
|
||||
SiteSetting.tl3_requires_topics_viewed_cap = 20
|
||||
expect(tl3_requirements.min_topics_viewed).to eq(20)
|
||||
end
|
||||
|
||||
it "min_posts_read depends on site setting and number of posts created" do
|
||||
SiteSetting.stubs(:tl3_requires_posts_read).returns(66)
|
||||
described_class.stubs(:num_posts_in_time_period).returns(1234)
|
||||
expect(tl3_requirements.min_posts_read).to eq(814)
|
||||
end
|
||||
|
||||
it "min_posts_read is capped" do
|
||||
SiteSetting.tl3_requires_posts_read = 66
|
||||
described_class.stubs(:num_posts_in_time_period).returns(1234)
|
||||
SiteSetting.tl3_requires_posts_read_cap = 600
|
||||
expect(tl3_requirements.min_posts_read).to eq(600)
|
||||
end
|
||||
|
||||
it "min_topics_viewed_all_time depends on site setting" do
|
||||
SiteSetting.stubs(:tl3_requires_topics_viewed_all_time).returns(75)
|
||||
expect(tl3_requirements.min_topics_viewed_all_time).to eq(75)
|
||||
|
@ -243,7 +257,7 @@ describe TrustLevel3Requirements do
|
|||
end
|
||||
end
|
||||
|
||||
describe "requirements" do
|
||||
context "requirements with defaults" do
|
||||
|
||||
before do
|
||||
tl3_requirements.stubs(:min_days_visited).returns(50)
|
||||
|
|
Loading…
Reference in New Issue
Block a user