Weigh staff votes more for New User of the Month badges
This commit is contained in:
parent
0829671963
commit
ebe232da47
|
@ -40,6 +40,7 @@ module Jobs
|
||||||
SUM(CASE
|
SUM(CASE
|
||||||
WHEN pa.id IS NOT NULL THEN
|
WHEN pa.id IS NOT NULL THEN
|
||||||
CASE
|
CASE
|
||||||
|
WHEN liked_by.admin OR liked_by.moderator THEN 2.0
|
||||||
WHEN liked_by.trust_level = 0 THEN 0.1
|
WHEN liked_by.trust_level = 0 THEN 0.1
|
||||||
WHEN liked_by.trust_level = 1 THEN 0.25
|
WHEN liked_by.trust_level = 1 THEN 0.25
|
||||||
WHEN liked_by.trust_level = 2 THEN 1.0
|
WHEN liked_by.trust_level = 2 THEN 1.0
|
||||||
|
|
|
@ -95,18 +95,26 @@ describe Jobs::GrantNewUserOfTheMonthBadges do
|
||||||
p = Fabricate(:post, user: user)
|
p = Fabricate(:post, user: user)
|
||||||
Fabricate(:post, user: user)
|
Fabricate(:post, user: user)
|
||||||
|
|
||||||
new_user = Fabricate(:user, created_at: 2.days.ago)
|
u0 = Fabricate(:user, trust_level: 0)
|
||||||
med_user = Fabricate(:user, created_at: 3.weeks.ago)
|
u1 = Fabricate(:user, trust_level: 1)
|
||||||
old_user = Fabricate(:user, created_at: 6.months.ago)
|
u2 = Fabricate(:user, trust_level: 2)
|
||||||
|
u3 = Fabricate(:user, trust_level: 3)
|
||||||
|
u4 = Fabricate(:user, trust_level: 4)
|
||||||
|
um = Fabricate(:user, trust_level: 3, moderator: true)
|
||||||
|
ua = Fabricate(:user, trust_level: 0, admin: true)
|
||||||
|
|
||||||
PostAction.act(new_user, p, PostActionType.types[:like])
|
PostAction.act(u0, p, PostActionType.types[:like])
|
||||||
PostAction.act(med_user, p, PostActionType.types[:like])
|
PostAction.act(u1, p, PostActionType.types[:like])
|
||||||
PostAction.act(old_user, p, PostActionType.types[:like])
|
PostAction.act(u2, p, PostActionType.types[:like])
|
||||||
expect(granter.scores[user.id]).to eq(0.375)
|
PostAction.act(u3, p, PostActionType.types[:like])
|
||||||
|
PostAction.act(u4, p, PostActionType.types[:like])
|
||||||
|
PostAction.act(um, p, PostActionType.types[:like])
|
||||||
|
PostAction.act(ua, p, PostActionType.types[:like])
|
||||||
|
expect(granter.scores[user.id]).to eq(4.425)
|
||||||
|
|
||||||
# It goes down the more they post
|
# It goes down the more they post
|
||||||
Fabricate(:post, user: user)
|
Fabricate(:post, user: user)
|
||||||
expect(granter.scores[user.id]).to eq(0.25)
|
expect(granter.scores[user.id]).to eq(2.95)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is limited to two accounts" do
|
it "is limited to two accounts" do
|
||||||
|
|
Loading…
Reference in New Issue