diff --git a/app/models/badge.rb b/app/models/badge.rb index 199e4428bf8..d6b69ea4db4 100644 --- a/app/models/badge.rb +++ b/app/models/badge.rb @@ -26,6 +26,8 @@ class Badge < ActiveRecord::Base PopularLink = 28 HotLink = 29 FamousLink = 30 + Appreciated = 36 + Respected = 37 Admired = 31 GivesBack = 32 OutOfLove = 33 @@ -200,17 +202,6 @@ SQL HAVING COUNT(p.id) > 0 SQL - Admired = <<-SQL - SELECT us.user_id, current_timestamp AS granted_at - FROM user_stats AS us - INNER JOIN posts AS p ON us.user_id = p.user_id - WHERE us.post_count > 500000 - AND p.like_count > 0 - AND (:backfill OR us.user_id IN (:user_ids)) - GROUP BY us.user_id, us.post_count - HAVING count(*)::float / us.post_count > 0.75 -SQL - GivesBack = <<-SQL SELECT us.user_id, current_timestamp AS granted_at FROM user_stats AS us @@ -286,6 +277,17 @@ SQL SQL end + def self.liked_posts(post_count, like_count) + <<-SQL + SELECT p.user_id, current_timestamp AS granted_at + FROM posts AS p + WHERE p.like_count >= #{like_count} + AND (:backfill OR p.user_id IN (:user_ids)) + GROUP BY p.user_id + HAVING count(*) > #{post_count} + SQL + end + def self.like_rate_limit(count) <<-SQL SELECT uh.target_user_id AS user_id, MAX(uh.created_at) AS granted_at diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index ac91569ce99..a7b658c4002 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -2964,15 +2964,27 @@ en: famous_link: name: Famous Link description: Posted an external link with at least 1000 clicks + appreciated: + name: Appreciated + description: Has received at least 1 like on 20 posts + respected: + name: Respected + description: Has received at least 2 likes on 100 posts admired: name: Admired - description: Has a high ratio of liked posts + description: Has received at least 5 likes on 300 posts gives_back: name: Gives Back description: Has a high ratio of likes given to likes received - generous: - name: Generous + out_of_love: + name: Out of Love description: Used the maximum amount of likes in a day + my_cup_runneth_over: + name: My Cup Runneth Over + description: Used the maximum amount of likes in a day 5 times + crazy_in_love: + name: Crazy in Love + description: Used the maximum amount of likes in a day 20 times google_search: |