From 07c6b720bccf7e4de824769660aa7fdbccfd45e4 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Wed, 4 Aug 2021 22:24:47 +0200 Subject: [PATCH] DEV: Remove `PostProcessed` trigger option (#13916) It was deprecated 5 years ago in https://github.com/discourse/discourse/commit/e55e2aff94959aecc28095875f5de351de26162f I've seen it still being used in the wild, even though it doesn't do anything anymore as I understand it. --- app/models/badge.rb | 11 +++++------ config/locales/client.en.yml | 1 - ...802131421_remove_post_processed_trigger_option.rb | 12 ++++++++++++ .../api/schemas/json/badge_list_response.json | 4 ---- 4 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 db/post_migrate/20210802131421_remove_post_processed_trigger_option.rb diff --git a/app/models/badge.rb b/app/models/badge.rb index bb9e0a67ccc..5e480aa2e57 100644 --- a/app/models/badge.rb +++ b/app/models/badge.rb @@ -75,11 +75,10 @@ class Badge < ActiveRecord::Base attr_accessor :has_badge def self.trigger_hash - Hash[*( - Badge::Trigger.constants.map { |k| - [k.to_s.underscore, Badge::Trigger.const_get(k)] - }.flatten - )] + @trigger_hash ||= Badge::Trigger.constants.map do |k| + name = k.to_s.underscore + [name, Badge::Trigger.const_get(k)] unless name =~ /deprecated/ + end.compact.to_h end module Trigger @@ -88,7 +87,7 @@ class Badge < ActiveRecord::Base PostRevision = 2 TrustLevelChange = 4 UserChange = 8 - PostProcessed = 16 # deprecated + DeprecatedPostProcessed = 16 # No longer in use def self.is_none?(trigger) [None].include? trigger diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 3062df4da35..5a3939be3ac 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -5221,7 +5221,6 @@ en: post_revision: "When a user edits or creates a post" trust_level_change: "When a user changes trust level" user_change: "When a user is edited or created" - post_processed: "After a post is processed" preview: link_text: "Preview granted badges" plan_text: "Preview with query plan" diff --git a/db/post_migrate/20210802131421_remove_post_processed_trigger_option.rb b/db/post_migrate/20210802131421_remove_post_processed_trigger_option.rb new file mode 100644 index 00000000000..1afd06e5c50 --- /dev/null +++ b/db/post_migrate/20210802131421_remove_post_processed_trigger_option.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class RemovePostProcessedTriggerOption < ActiveRecord::Migration[6.1] + def up + # Replace Badge::Trigger::PostProcessed (16) with None (0) + DB.exec("UPDATE badges SET trigger = 0 WHERE trigger = 16") + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end diff --git a/spec/requests/api/schemas/json/badge_list_response.json b/spec/requests/api/schemas/json/badge_list_response.json index 6179c106cfd..a601321a64f 100644 --- a/spec/requests/api/schemas/json/badge_list_response.json +++ b/spec/requests/api/schemas/json/badge_list_response.json @@ -198,9 +198,6 @@ "trust_level_change": { "type": "integer" }, - "post_processed": { - "type": "integer" - }, "post_action": { "type": "integer" } @@ -210,7 +207,6 @@ "none", "post_revision", "trust_level_change", - "post_processed", "post_action" ] },