mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 23:07:28 +08:00
FEATURE: sharing badges (nice share, good share, great share)
FIX: bad translation
This commit is contained in:
@ -16,6 +16,9 @@ class Badge < ActiveRecord::Base
|
|||||||
NiceTopic = 18
|
NiceTopic = 18
|
||||||
GoodTopic = 19
|
GoodTopic = 19
|
||||||
GreatTopic = 20
|
GreatTopic = 20
|
||||||
|
NiceShare = 21
|
||||||
|
GoodShare = 22
|
||||||
|
GreatShare = 23
|
||||||
|
|
||||||
# other consts
|
# other consts
|
||||||
AutobiographerMinBioLength = 10
|
AutobiographerMinBioLength = 10
|
||||||
@ -187,6 +190,22 @@ SQL
|
|||||||
)
|
)
|
||||||
"
|
"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.sharing_badge(count)
|
||||||
|
<<SQL
|
||||||
|
SELECT views.user_id, i2.post_id, i2.created_at granted_at
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
SELECT i.user_id, MIN(i.id) i_id
|
||||||
|
FROM incoming_links i
|
||||||
|
JOIN badge_posts p on p.id = i.post_id
|
||||||
|
WHERE i.user_id IS NOT NULL
|
||||||
|
GROUP BY i.user_id,i.post_id
|
||||||
|
HAVING COUNT(*) > #{count}
|
||||||
|
) as views
|
||||||
|
JOIN incoming_links i2 ON i2.id = views.i_id
|
||||||
|
SQL
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
belongs_to :badge_type
|
belongs_to :badge_type
|
||||||
|
@ -2184,12 +2184,21 @@ en:
|
|||||||
nice_topic:
|
nice_topic:
|
||||||
name: Nice Topic
|
name: Nice Topic
|
||||||
description: Received 10 likes on a topic. This badge can be granted multiple times
|
description: Received 10 likes on a topic. This badge can be granted multiple times
|
||||||
good_post:
|
good_topic:
|
||||||
name: Good Topic
|
name: Good Topic
|
||||||
description: Received 25 likes on a topic. This badge can be granted multiple times
|
description: Received 25 likes on a topic. This badge can be granted multiple times
|
||||||
great_post:
|
great_topic:
|
||||||
name: Great Topic
|
name: Great Topic
|
||||||
description: Received 50 likes on a topic. This badge can be granted multiple times
|
description: Received 50 likes on a topic. This badge can be granted multiple times
|
||||||
|
nice_share:
|
||||||
|
name: Nice Share
|
||||||
|
description: Shared a post with 25 unique visitors
|
||||||
|
good_share:
|
||||||
|
name: Good Share
|
||||||
|
description: Shared a post with 300 unique visitors
|
||||||
|
great_share:
|
||||||
|
name: Great Share
|
||||||
|
description: Shared a post with 1000 unique visitors
|
||||||
first_like:
|
first_like:
|
||||||
name: First Like
|
name: First Like
|
||||||
description: Liked a post
|
description: Liked a post
|
||||||
|
@ -153,6 +153,28 @@ Badge.seed do |b|
|
|||||||
b.system = true
|
b.system = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
[
|
||||||
|
[Badge::NiceShare, "Nice Share", BadgeType::Bronze, 25],
|
||||||
|
[Badge::GoodShare, "Good Share", BadgeType::Silver, 300],
|
||||||
|
[Badge::GreatShare, "Great Share", BadgeType::Gold, 1000],
|
||||||
|
].each do |spec|
|
||||||
|
|
||||||
|
id, name, level, count = spec
|
||||||
|
Badge.seed do |b|
|
||||||
|
b.id = id
|
||||||
|
b.default_name = name
|
||||||
|
b.badge_type_id = level
|
||||||
|
b.multiple_grant = true
|
||||||
|
b.target_posts = true
|
||||||
|
b.show_posts = true
|
||||||
|
b.query = Badge::Queries.sharing_badge(count)
|
||||||
|
b.default_badge_grouping_id = BadgeGrouping::Community
|
||||||
|
# don't trigger for now, its too expensive
|
||||||
|
b.trigger = Badge::Trigger::None
|
||||||
|
b.system = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Badge.seed do |b|
|
Badge.seed do |b|
|
||||||
b.id = Badge::Welcome
|
b.id = Badge::Welcome
|
||||||
b.default_name = "Welcome"
|
b.default_name = "Welcome"
|
||||||
|
Reference in New Issue
Block a user