mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
Adjusted "Gives Back" badge
This commit is contained in:
parent
35c2339c2a
commit
7c384fc740
3 changed files with 47 additions and 25 deletions
|
@ -20,20 +20,27 @@ class Badge < ActiveRecord::Base
|
|||
GoodShare = 22
|
||||
GreatShare = 23
|
||||
OneYearAnniversary = 24
|
||||
|
||||
Promoter = 25
|
||||
Campaigner = 26
|
||||
Champion = 27
|
||||
|
||||
PopularLink = 28
|
||||
HotLink = 29
|
||||
FamousLink = 30
|
||||
|
||||
Appreciated = 36
|
||||
Respected = 37
|
||||
Admired = 31
|
||||
GivesBack = 32
|
||||
|
||||
OutOfLove = 33
|
||||
MyCupRunnethOver = 34
|
||||
CrazyInLove = 35
|
||||
|
||||
ThankYou = 38
|
||||
GivesBack = 32
|
||||
Empathetic = 39
|
||||
|
||||
# other consts
|
||||
AutobiographerMinBioLength = 10
|
||||
|
||||
|
@ -202,17 +209,6 @@ SQL
|
|||
HAVING COUNT(p.id) > 0
|
||||
SQL
|
||||
|
||||
GivesBack = <<-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 p.like_count > 0
|
||||
AND us.post_count > 50000
|
||||
AND (:backfill OR us.user_id IN (:user_ids))
|
||||
GROUP BY us.user_id
|
||||
HAVING us.likes_given::float / count(*) > 5.0
|
||||
SQL
|
||||
|
||||
def self.invite_badge(count,trust_level)
|
||||
"
|
||||
SELECT u.id user_id, current_timestamp granted_at
|
||||
|
@ -299,6 +295,18 @@ SQL
|
|||
SQL
|
||||
end
|
||||
|
||||
def self.liked_back(min_posts, ratio)
|
||||
<<-SQL
|
||||
SELECT p.user_id, current_timestamp AS granted_at
|
||||
FROM posts AS p
|
||||
INNER JOIN user_stats AS us ON us.user_id = p.user_id
|
||||
WHERE p.like_count > 0
|
||||
AND (:backfill OR p.user_id IN (:user_ids))
|
||||
GROUP BY p.user_id, us.likes_given
|
||||
HAVING count(*) > #{min_posts}
|
||||
AND (us.likes_given / count(*)::float) > #{ratio}
|
||||
SQL
|
||||
end
|
||||
end
|
||||
|
||||
belongs_to :badge_type
|
||||
|
|
|
@ -2973,9 +2973,6 @@ en:
|
|||
admired:
|
||||
name: Admired
|
||||
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
|
||||
out_of_love:
|
||||
name: Out of Love
|
||||
description: Used the maximum amount of likes in a day
|
||||
|
@ -2985,6 +2982,15 @@ en:
|
|||
crazy_in_love:
|
||||
name: Crazy in Love
|
||||
description: Used the maximum amount of likes in a day 20 times
|
||||
thank_you:
|
||||
name: Thank You
|
||||
description: Has at least 6 liked posts and a high like ratio
|
||||
gives_back:
|
||||
name: Gives Back
|
||||
description: Has at least 100 liked posts and a very high like ratio
|
||||
empathetic:
|
||||
name: Empathetic
|
||||
description: Has at least 500 liked posts and a superlative like ratio
|
||||
|
||||
google_search: |
|
||||
<h3>Search with Google</h3>
|
||||
|
|
|
@ -312,16 +312,24 @@ end
|
|||
end
|
||||
end
|
||||
|
||||
Badge.seed do |b|
|
||||
b.id = Badge::GivesBack
|
||||
b.default_name = "Gives Back"
|
||||
b.default_icon = "fa-heart"
|
||||
b.badge_type_id = BadgeType::Silver
|
||||
b.query = Badge::Queries::GivesBack
|
||||
b.default_badge_grouping_id = BadgeGrouping::Community
|
||||
b.trigger = Badge::Trigger::None
|
||||
b.auto_revoke = false
|
||||
b.system = true
|
||||
|
||||
[
|
||||
[Badge::ThankYou, "Thank You", BadgeType::Bronze, 6, 0.50],
|
||||
[Badge::GivesBack, "Gives Back", BadgeType::Silver, 100, 1.0],
|
||||
[Badge::Empathetic, "Empathetic", BadgeType::Gold, 500, 2.0],
|
||||
].each do |spec|
|
||||
id, name, level, count, ratio = spec
|
||||
Badge.seed do |b|
|
||||
b.id = id
|
||||
b.default_name = name
|
||||
b.default_icon = "fa-heart"
|
||||
b.badge_type_id = level
|
||||
b.query = Badge::Queries.liked_back(count, ratio)
|
||||
b.default_badge_grouping_id = BadgeGrouping::Community
|
||||
b.trigger = Badge::Trigger::None
|
||||
b.auto_revoke = false
|
||||
b.system = true
|
||||
end
|
||||
end
|
||||
|
||||
[
|
||||
|
|
Loading…
Reference in a new issue