mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 03:06:53 +08:00
FEATURE: Admired Badge for high like ratio
This commit is contained in:
@ -26,6 +26,7 @@ class Badge < ActiveRecord::Base
|
|||||||
PopularLink = 28
|
PopularLink = 28
|
||||||
HotLink = 29
|
HotLink = 29
|
||||||
FamousLink = 30
|
FamousLink = 30
|
||||||
|
Admired = 31
|
||||||
|
|
||||||
# other consts
|
# other consts
|
||||||
AutobiographerMinBioLength = 10
|
AutobiographerMinBioLength = 10
|
||||||
@ -195,6 +196,17 @@ SQL
|
|||||||
HAVING COUNT(p.id) > 0
|
HAVING COUNT(p.id) > 0
|
||||||
SQL
|
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)
|
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
|
||||||
|
@ -2964,6 +2964,9 @@ en:
|
|||||||
famous_link:
|
famous_link:
|
||||||
name: Famous Link
|
name: Famous Link
|
||||||
description: Posted an external link with at least 1000 clicks
|
description: Posted an external link with at least 1000 clicks
|
||||||
|
admired:
|
||||||
|
name: Admired
|
||||||
|
description: Has a high ratio of liked posts
|
||||||
|
|
||||||
google_search: |
|
google_search: |
|
||||||
<h3>Search with Google</h3>
|
<h3>Search with Google</h3>
|
||||||
|
@ -292,6 +292,18 @@ end
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Badge.seed do |b|
|
||||||
|
b.id = Badge::Admired
|
||||||
|
b.default_name = "Admired"
|
||||||
|
b.default_icon = "fa-heart"
|
||||||
|
b.badge_type_id = BadgeType::Gold
|
||||||
|
b.query = Badge::Queries::Admired
|
||||||
|
b.default_badge_grouping_id = BadgeGrouping::Community
|
||||||
|
b.trigger = Badge::Trigger::None
|
||||||
|
b.auto_revoke = true
|
||||||
|
b.system = true
|
||||||
|
end
|
||||||
|
|
||||||
Badge.where("NOT system AND id < 100").each do |badge|
|
Badge.where("NOT system AND id < 100").each do |badge|
|
||||||
new_id = [Badge.maximum(:id) + 1, 100].max
|
new_id = [Badge.maximum(:id) + 1, 100].max
|
||||||
old_id = badge.id
|
old_id = badge.id
|
||||||
|
Reference in New Issue
Block a user