DEV: Remove `PostProcessed` trigger option (#13916)

DEV: Remove PostProcessed trigger option (#13916)

It was deprecated 5 years ago in FIX: FirstReplyByEmail badge wasn't granted · discourse/discourse@e55e2af · GitHub

I’ve seen it still being used in the wild, even though it doesn’t do anything anymore as I understand it.

diff --git a/app/models/badge.rb b/app/models/badge.rb
index bb9e0a6..5e480aa 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 3062df4..5a3939b 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 0000000..1afd06e
--- /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 6179c10..a601321 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"
           ]
         },

GitHub sha: 07c6b720bccf7e4de824769660aa7fdbccfd45e4

This commit appears in #13916 which was approved by eviltrout and ZogStriP. It was merged by CvX.