mirror of
https://github.com/discourse/discourse.git
synced 2025-02-17 09:42:45 +08:00
Updated badges for receiving likes
This commit is contained in:
parent
25c26dcd51
commit
35c2339c2a
|
@ -26,6 +26,8 @@ class Badge < ActiveRecord::Base
|
|||
PopularLink = 28
|
||||
HotLink = 29
|
||||
FamousLink = 30
|
||||
Appreciated = 36
|
||||
Respected = 37
|
||||
Admired = 31
|
||||
GivesBack = 32
|
||||
OutOfLove = 33
|
||||
|
@ -200,17 +202,6 @@ 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 > 500000
|
||||
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
|
||||
|
||||
GivesBack = <<-SQL
|
||||
SELECT us.user_id, current_timestamp AS granted_at
|
||||
FROM user_stats AS us
|
||||
|
@ -286,6 +277,17 @@ SQL
|
|||
SQL
|
||||
end
|
||||
|
||||
def self.liked_posts(post_count, like_count)
|
||||
<<-SQL
|
||||
SELECT p.user_id, current_timestamp AS granted_at
|
||||
FROM posts AS p
|
||||
WHERE p.like_count >= #{like_count}
|
||||
AND (:backfill OR p.user_id IN (:user_ids))
|
||||
GROUP BY p.user_id
|
||||
HAVING count(*) > #{post_count}
|
||||
SQL
|
||||
end
|
||||
|
||||
def self.like_rate_limit(count)
|
||||
<<-SQL
|
||||
SELECT uh.target_user_id AS user_id, MAX(uh.created_at) AS granted_at
|
||||
|
|
|
@ -2964,15 +2964,27 @@ en:
|
|||
famous_link:
|
||||
name: Famous Link
|
||||
description: Posted an external link with at least 1000 clicks
|
||||
appreciated:
|
||||
name: Appreciated
|
||||
description: Has received at least 1 like on 20 posts
|
||||
respected:
|
||||
name: Respected
|
||||
description: Has received at least 2 likes on 100 posts
|
||||
admired:
|
||||
name: Admired
|
||||
description: Has a high ratio of liked 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
|
||||
generous:
|
||||
name: Generous
|
||||
out_of_love:
|
||||
name: Out of Love
|
||||
description: Used the maximum amount of likes in a day
|
||||
my_cup_runneth_over:
|
||||
name: My Cup Runneth Over
|
||||
description: Used the maximum amount of likes in a day 5 times
|
||||
crazy_in_love:
|
||||
name: Crazy in Love
|
||||
description: Used the maximum amount of likes in a day 20 times
|
||||
|
||||
google_search: |
|
||||
<h3>Search with Google</h3>
|
||||
|
|
|
@ -292,16 +292,24 @@ 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 = false
|
||||
b.system = true
|
||||
[
|
||||
[Badge::Appreciated, "Appreciated", BadgeType::Bronze, 1, 20],
|
||||
[Badge::Respected, "Respected", BadgeType::Silver, 2, 100],
|
||||
[Badge::Admired, "Admired", BadgeType::Gold, 5, 300],
|
||||
].each do |spec|
|
||||
id, name, level, like_count, post_count = spec
|
||||
Badge.seed do |b|
|
||||
b.id = id
|
||||
b.name = name
|
||||
b.default_name = name
|
||||
b.default_icon = "fa-heart"
|
||||
b.badge_type_id = level
|
||||
b.query = Badge::Queries.liked_posts(post_count, like_count)
|
||||
b.default_badge_grouping_id = BadgeGrouping::Community
|
||||
b.trigger = Badge::Trigger::None
|
||||
b.auto_revoke = false
|
||||
b.system = true
|
||||
end
|
||||
end
|
||||
|
||||
Badge.seed do |b|
|
||||
|
|
Loading…
Reference in New Issue
Block a user