mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-17 04:01:29 -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
|
GoodShare = 22
|
||||||
GreatShare = 23
|
GreatShare = 23
|
||||||
OneYearAnniversary = 24
|
OneYearAnniversary = 24
|
||||||
|
|
||||||
Promoter = 25
|
Promoter = 25
|
||||||
Campaigner = 26
|
Campaigner = 26
|
||||||
Champion = 27
|
Champion = 27
|
||||||
|
|
||||||
PopularLink = 28
|
PopularLink = 28
|
||||||
HotLink = 29
|
HotLink = 29
|
||||||
FamousLink = 30
|
FamousLink = 30
|
||||||
|
|
||||||
Appreciated = 36
|
Appreciated = 36
|
||||||
Respected = 37
|
Respected = 37
|
||||||
Admired = 31
|
Admired = 31
|
||||||
GivesBack = 32
|
|
||||||
OutOfLove = 33
|
OutOfLove = 33
|
||||||
MyCupRunnethOver = 34
|
MyCupRunnethOver = 34
|
||||||
CrazyInLove = 35
|
CrazyInLove = 35
|
||||||
|
|
||||||
|
ThankYou = 38
|
||||||
|
GivesBack = 32
|
||||||
|
Empathetic = 39
|
||||||
|
|
||||||
# other consts
|
# other consts
|
||||||
AutobiographerMinBioLength = 10
|
AutobiographerMinBioLength = 10
|
||||||
|
|
||||||
|
@ -202,17 +209,6 @@ SQL
|
||||||
HAVING COUNT(p.id) > 0
|
HAVING COUNT(p.id) > 0
|
||||||
SQL
|
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)
|
def self.invite_badge(count,trust_level)
|
||||||
"
|
"
|
||||||
SELECT u.id user_id, current_timestamp granted_at
|
SELECT u.id user_id, current_timestamp granted_at
|
||||||
|
@ -299,6 +295,18 @@ SQL
|
||||||
SQL
|
SQL
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
belongs_to :badge_type
|
belongs_to :badge_type
|
||||||
|
|
|
@ -2973,9 +2973,6 @@ en:
|
||||||
admired:
|
admired:
|
||||||
name: Admired
|
name: Admired
|
||||||
description: Has received at least 5 likes on 300 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
|
|
||||||
out_of_love:
|
out_of_love:
|
||||||
name: Out of Love
|
name: Out of Love
|
||||||
description: Used the maximum amount of likes in a day
|
description: Used the maximum amount of likes in a day
|
||||||
|
@ -2985,6 +2982,15 @@ en:
|
||||||
crazy_in_love:
|
crazy_in_love:
|
||||||
name: Crazy in Love
|
name: Crazy in Love
|
||||||
description: Used the maximum amount of likes in a day 20 times
|
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: |
|
google_search: |
|
||||||
<h3>Search with Google</h3>
|
<h3>Search with Google</h3>
|
||||||
|
|
|
@ -312,16 +312,24 @@ end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Badge.seed do |b|
|
|
||||||
b.id = Badge::GivesBack
|
[
|
||||||
b.default_name = "Gives Back"
|
[Badge::ThankYou, "Thank You", BadgeType::Bronze, 6, 0.50],
|
||||||
b.default_icon = "fa-heart"
|
[Badge::GivesBack, "Gives Back", BadgeType::Silver, 100, 1.0],
|
||||||
b.badge_type_id = BadgeType::Silver
|
[Badge::Empathetic, "Empathetic", BadgeType::Gold, 500, 2.0],
|
||||||
b.query = Badge::Queries::GivesBack
|
].each do |spec|
|
||||||
b.default_badge_grouping_id = BadgeGrouping::Community
|
id, name, level, count, ratio = spec
|
||||||
b.trigger = Badge::Trigger::None
|
Badge.seed do |b|
|
||||||
b.auto_revoke = false
|
b.id = id
|
||||||
b.system = true
|
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
|
end
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in a new issue