FEATURE: Add Wiki Editor badge. (#6511)

This commit is contained in:
Bianca Nenciu
2018-10-19 16:30:27 +03:00
committed by Régis Hanol
parent 637123ff6f
commit b69652278f
4 changed files with 28 additions and 0 deletions

View File

@ -15,6 +15,7 @@ class Badge < ActiveRecord::Base
GreatPost = 8 GreatPost = 8
Autobiographer = 9 Autobiographer = 9
Editor = 10 Editor = 10
WikiEditor = 48
FirstLike = 11 FirstLike = 11
FirstShare = 12 FirstShare = 12

View File

@ -3655,6 +3655,11 @@ en:
description: First post edit description: First post edit
long_description: | long_description: |
This badge is granted the first time you edit one of your posts. While you won’t be able to edit your posts forever, editing is encouraged — you can improve the formatting, fix small mistakes, or add anything you missed when you originally posted. Edit to make your posts even better! This badge is granted the first time you edit one of your posts. While you won’t be able to edit your posts forever, editing is encouraged — you can improve the formatting, fix small mistakes, or add anything you missed when you originally posted. Edit to make your posts even better!
wiki_editor:
name: Wiki Editor
description: First wiki edit
long_description: |
This badge is granted the first time you edit one wiki post.
basic_user: basic_user:
name: Basic name: Basic
description: <a href="https://blog.discourse.org/2018/06/understanding-discourse-trust-levels/">Granted</a> all essential community functions description: <a href="https://blog.discourse.org/2018/06/understanding-discourse-trust-levels/">Granted</a> all essential community functions

View File

@ -233,6 +233,19 @@ Badge.seed do |b|
b.system = true b.system = true
end end
Badge.seed do |b|
b.id = Badge::WikiEditor
b.name = "Wiki Editor"
b.badge_type_id = BadgeType::Bronze
b.multiple_grant = false
b.target_posts = true
b.query = BadgeQueries::WikiEditor
b.badge_grouping_id = BadgeGrouping::GettingStarted
b.default_badge_grouping_id = BadgeGrouping::GettingStarted
b.trigger = Badge::Trigger::PostRevision
b.system = true
end
[ [
[Badge::NicePost, "Nice Post", BadgeType::Bronze, false], [Badge::NicePost, "Nice Post", BadgeType::Bronze, false],
[Badge::GoodPost, "Good Post", BadgeType::Silver, false], [Badge::GoodPost, "Good Post", BadgeType::Silver, false],

View File

@ -99,6 +99,15 @@ SQL
GROUP BY p.user_id GROUP BY p.user_id
SQL SQL
WikiEditor = <<~SQL
SELECT DISTINCT ON (pr.user_id) pr.user_id, pr.post_id, pr.created_at granted_at
FROM post_revisions pr
JOIN badge_posts p on p.id = pr.post_id
WHERE p.wiki
AND NOT pr.hidden
AND (:backfill OR p.id IN (:post_ids))
SQL
Welcome = <<SQL Welcome = <<SQL
SELECT p.user_id, min(post_id) post_id, min(pa.created_at) granted_at SELECT p.user_id, min(post_id) post_id, min(pa.created_at) granted_at
FROM post_actions pa FROM post_actions pa