mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FEATURE: Gives Back badge
This commit is contained in:
parent
e60da531ba
commit
cfe18c3f5b
3 changed files with 27 additions and 1 deletions
|
@ -27,6 +27,7 @@ class Badge < ActiveRecord::Base
|
||||||
HotLink = 29
|
HotLink = 29
|
||||||
FamousLink = 30
|
FamousLink = 30
|
||||||
Admired = 31
|
Admired = 31
|
||||||
|
GivesBack = 32
|
||||||
|
|
||||||
# other consts
|
# other consts
|
||||||
AutobiographerMinBioLength = 10
|
AutobiographerMinBioLength = 10
|
||||||
|
@ -207,6 +208,16 @@ SQL
|
||||||
HAVING count(*)::float / us.post_count > 0.75
|
HAVING count(*)::float / us.post_count > 0.75
|
||||||
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 (: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
|
||||||
|
|
|
@ -2967,6 +2967,9 @@ en:
|
||||||
admired:
|
admired:
|
||||||
name: Admired
|
name: Admired
|
||||||
description: Has a high ratio of liked posts
|
description: Has a high ratio of liked posts
|
||||||
|
gives_back:
|
||||||
|
name: Gives Back
|
||||||
|
description: Has a high ratio of likes given to likes received
|
||||||
|
|
||||||
google_search: |
|
google_search: |
|
||||||
<h3>Search with Google</h3>
|
<h3>Search with Google</h3>
|
||||||
|
|
|
@ -300,7 +300,19 @@ Badge.seed do |b|
|
||||||
b.query = Badge::Queries::Admired
|
b.query = Badge::Queries::Admired
|
||||||
b.default_badge_grouping_id = BadgeGrouping::Community
|
b.default_badge_grouping_id = BadgeGrouping::Community
|
||||||
b.trigger = Badge::Trigger::None
|
b.trigger = Badge::Trigger::None
|
||||||
b.auto_revoke = true
|
b.auto_revoke = false
|
||||||
|
b.system = true
|
||||||
|
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
|
b.system = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue