FEATURE: Admired Badge for high like ratio

This commit is contained in:
Robin Ward
2016-03-15 14:14:10 -04:00
parent fb6bd10d4c
commit e60da531ba
3 changed files with 27 additions and 0 deletions

View File

@ -26,6 +26,7 @@ class Badge < ActiveRecord::Base
PopularLink = 28
HotLink = 29
FamousLink = 30
Admired = 31
# other consts
AutobiographerMinBioLength = 10
@ -195,6 +196,17 @@ 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 > 5
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
def self.invite_badge(count,trust_level)
"
SELECT u.id user_id, current_timestamp granted_at