mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06: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
|
PopularLink = 28
|
||||||
HotLink = 29
|
HotLink = 29
|
||||||
FamousLink = 30
|
FamousLink = 30
|
||||||
|
Appreciated = 36
|
||||||
|
Respected = 37
|
||||||
Admired = 31
|
Admired = 31
|
||||||
GivesBack = 32
|
GivesBack = 32
|
||||||
OutOfLove = 33
|
OutOfLove = 33
|
||||||
@ -200,17 +202,6 @@ 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 > 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
|
GivesBack = <<-SQL
|
||||||
SELECT us.user_id, current_timestamp AS granted_at
|
SELECT us.user_id, current_timestamp AS granted_at
|
||||||
FROM user_stats AS us
|
FROM user_stats AS us
|
||||||
@ -286,6 +277,17 @@ SQL
|
|||||||
SQL
|
SQL
|
||||||
end
|
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)
|
def self.like_rate_limit(count)
|
||||||
<<-SQL
|
<<-SQL
|
||||||
SELECT uh.target_user_id AS user_id, MAX(uh.created_at) AS granted_at
|
SELECT uh.target_user_id AS user_id, MAX(uh.created_at) AS granted_at
|
||||||
|
@ -2964,15 +2964,27 @@ 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
|
||||||
|
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:
|
admired:
|
||||||
name: Admired
|
name: Admired
|
||||||
description: Has a high ratio of liked posts
|
description: Has received at least 5 likes on 300 posts
|
||||||
gives_back:
|
gives_back:
|
||||||
name: Gives Back
|
name: Gives Back
|
||||||
description: Has a high ratio of likes given to likes received
|
description: Has a high ratio of likes given to likes received
|
||||||
generous:
|
out_of_love:
|
||||||
name: Generous
|
name: Out of Love
|
||||||
description: Used the maximum amount of likes in a day
|
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: |
|
google_search: |
|
||||||
<h3>Search with Google</h3>
|
<h3>Search with Google</h3>
|
||||||
|
@ -292,17 +292,25 @@ end
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
[
|
||||||
|
[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|
|
Badge.seed do |b|
|
||||||
b.id = Badge::Admired
|
b.id = id
|
||||||
b.default_name = "Admired"
|
b.name = name
|
||||||
|
b.default_name = name
|
||||||
b.default_icon = "fa-heart"
|
b.default_icon = "fa-heart"
|
||||||
b.badge_type_id = BadgeType::Gold
|
b.badge_type_id = level
|
||||||
b.query = Badge::Queries::Admired
|
b.query = Badge::Queries.liked_posts(post_count, like_count)
|
||||||
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 = false
|
b.auto_revoke = false
|
||||||
b.system = true
|
b.system = true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Badge.seed do |b|
|
Badge.seed do |b|
|
||||||
b.id = Badge::GivesBack
|
b.id = Badge::GivesBack
|
||||||
|
Loading…
Reference in New Issue
Block a user