From b69652278f760c9d35fc8682f1d430c47cfa29c0 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Fri, 19 Oct 2018 16:30:27 +0300 Subject: [PATCH] FEATURE: Add Wiki Editor badge. (#6511) --- app/models/badge.rb | 1 + config/locales/server.en.yml | 5 +++++ db/fixtures/006_badges.rb | 13 +++++++++++++ lib/badge_queries.rb | 9 +++++++++ 4 files changed, 28 insertions(+) diff --git a/app/models/badge.rb b/app/models/badge.rb index 7ab289cf134..c7c6c40b307 100644 --- a/app/models/badge.rb +++ b/app/models/badge.rb @@ -15,6 +15,7 @@ class Badge < ActiveRecord::Base GreatPost = 8 Autobiographer = 9 Editor = 10 + WikiEditor = 48 FirstLike = 11 FirstShare = 12 diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 1b841ad84c3..c1ba5847b76 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -3655,6 +3655,11 @@ en: description: First post edit 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! + 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: name: Basic description: Granted all essential community functions diff --git a/db/fixtures/006_badges.rb b/db/fixtures/006_badges.rb index eae24fec16f..6008cd93e8e 100644 --- a/db/fixtures/006_badges.rb +++ b/db/fixtures/006_badges.rb @@ -233,6 +233,19 @@ Badge.seed do |b| b.system = true 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::GoodPost, "Good Post", BadgeType::Silver, false], diff --git a/lib/badge_queries.rb b/lib/badge_queries.rb index f28e98f8732..dec8a45a760 100644 --- a/lib/badge_queries.rb +++ b/lib/badge_queries.rb @@ -99,6 +99,15 @@ SQL GROUP BY p.user_id 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 = <