Change New User of the Month Badge to use trust level rather than age

This commit is contained in:
Robin Ward 2017-03-31 16:56:58 -04:00
parent a8d3779f0b
commit e4b1376146
2 changed files with 7 additions and 4 deletions

View File

@ -33,8 +33,11 @@ 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.created_at > (CURRENT_TIMESTAMP - '1 week'::INTERVAL) THEN 0.1 WHEN liked_by.trust_level = 0 THEN 0.1
WHEN liked_by.created_at > (CURRENT_TIMESTAMP - '1 month'::INTERVAL) THEN 0.5 WHEN liked_by.trust_level = 1 THEN 0.25
WHEN liked_by.trust_level = 2 THEN 1.0
WHEN liked_by.trust_level = 3 THEN 1.5
WHEN liked_by.trust_level = 4 THEN 2.0
ELSE 1.0 ELSE 1.0
END END
ELSE 0 ELSE 0

View File

@ -64,11 +64,11 @@ describe Jobs::GrantNewUserOfTheMonthBadges do
PostAction.act(new_user, p, PostActionType.types[:like]) PostAction.act(new_user, p, PostActionType.types[:like])
PostAction.act(med_user, p, PostActionType.types[:like]) PostAction.act(med_user, p, PostActionType.types[:like])
PostAction.act(old_user, p, PostActionType.types[:like]) PostAction.act(old_user, p, PostActionType.types[:like])
expect(granter.scores[user.id]).to eq(0.4) expect(granter.scores[user.id]).to eq(0.1875)
# 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.32) expect(granter.scores[user.id]).to eq(0.15)
end end
it "is limited to two accounts" do it "is limited to two accounts" do