From e4b1376146d825a1a910e357987cce9b81a7286b Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 31 Mar 2017 16:56:58 -0400 Subject: [PATCH] Change New User of the Month Badge to use trust level rather than age --- app/jobs/scheduled/grant_new_user_of_the_month_badges.rb | 7 +++++-- spec/jobs/grant_new_user_of_the_month_badges_spec.rb | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb b/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb index 38f3350f78f..1bc257ee2ae 100644 --- a/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb +++ b/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb @@ -33,8 +33,11 @@ module Jobs SUM(CASE WHEN pa.id IS NOT NULL THEN CASE - WHEN liked_by.created_at > (CURRENT_TIMESTAMP - '1 week'::INTERVAL) THEN 0.1 - WHEN liked_by.created_at > (CURRENT_TIMESTAMP - '1 month'::INTERVAL) THEN 0.5 + WHEN liked_by.trust_level = 0 THEN 0.1 + 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 END ELSE 0 diff --git a/spec/jobs/grant_new_user_of_the_month_badges_spec.rb b/spec/jobs/grant_new_user_of_the_month_badges_spec.rb index a727edbe885..122c8762a40 100644 --- a/spec/jobs/grant_new_user_of_the_month_badges_spec.rb +++ b/spec/jobs/grant_new_user_of_the_month_badges_spec.rb @@ -64,11 +64,11 @@ describe Jobs::GrantNewUserOfTheMonthBadges do PostAction.act(new_user, p, PostActionType.types[:like]) PostAction.act(med_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 Fabricate(:post, user: user) - expect(granter.scores[user.id]).to eq(0.32) + expect(granter.scores[user.id]).to eq(0.15) end it "is limited to two accounts" do