diff --git a/app/controllers/pet_states_controller.rb b/app/controllers/pet_states_controller.rb index 4fc7d5339..4d6ee0645 100644 --- a/app/controllers/pet_states_controller.rb +++ b/app/controllers/pet_states_controller.rb @@ -35,10 +35,7 @@ class PetStatesController < ApplicationController end def next_unlabeled_appearance_path - # Rather than just getting the newest unlabeled pet state, prioritize the - # newest *pet type*. This better matches the user's perception of what the - # newest state is, because the Rainbow Pool UI is grouped by pet type! - unlabeled_appearance = PetState.needs_labeling.newest_pet_type.newest.first + unlabeled_appearance = PetState.next_unlabeled_appearance if unlabeled_appearance edit_pet_type_pet_state_path( diff --git a/app/controllers/pet_types_controller.rb b/app/controllers/pet_types_controller.rb index 8fa2f524b..82e1f2f57 100644 --- a/app/controllers/pet_types_controller.rb +++ b/app/controllers/pet_types_controller.rb @@ -35,6 +35,16 @@ class PetTypesController < ApplicationController if @selected_species && @selected_color && @pet_types.size == 1 redirect_to @pet_types.first end + + if support_staff? + @counts = { + total: PetState.count, + glitched: PetState.glitched.count, + needs_labeling: PetState.needs_labeling.count, + usable: PetState.usable.count, + } + @unlabeled_appearance = PetState.next_unlabeled_appearance + end } format.json { diff --git a/app/models/pet_state.rb b/app/models/pet_state.rb index 17b027ed8..fc785e11f 100644 --- a/app/models/pet_state.rb +++ b/app/models/pet_state.rb @@ -17,10 +17,13 @@ class PetState < ApplicationRecord alias_method :swf_asset_ids_from_association, :swf_asset_ids + scope :glitched, -> { where(glitched: true) } + scope :needs_labeling, -> { unlabeled.where(glitched: false) } + scope :unlabeled, -> { with_pose("UNKNOWN") } + scope :usable, -> { where(labeled: true, glitched: false) } + scope :newest, -> { order(created_at: :desc) } scope :newest_pet_type, -> { joins(:pet_type).merge(PetType.newest) } - scope :unlabeled, -> { with_pose("UNKNOWN") } - scope :needs_labeling, -> { unlabeled.where(glitched: false) } # A simple ordering that tries to bring reliable pet states to the front. scope :emotion_order, -> { @@ -138,5 +141,12 @@ class PetState < ApplicationRecord end end end + + def self.next_unlabeled_appearance + # Rather than just getting the newest unlabeled pet state, prioritize the + # newest *pet type*. This better matches the user's perception of what the + # newest state is, because the Rainbow Pool UI is grouped by pet type! + needs_labeling.newest_pet_type.newest.first + end end diff --git a/app/views/pet_types/index.html.haml b/app/views/pet_types/index.html.haml index e9c48af60..ef25ab9a7 100644 --- a/app/views/pet_types/index.html.haml +++ b/app/views/pet_types/index.html.haml @@ -10,6 +10,18 @@ [1]: #{alt_styles_path} +- if support_staff? + %p + %strong 💡 Support summary: + ✅ #{number_with_delimiter @counts[:usable]} usable + + 👾 #{number_with_delimiter @counts[:glitched]} glitched + - if @unlabeled_appearance + + ❓️ + = link_to "#{number_with_delimiter @counts[:needs_labeling]} unknown", + edit_pet_type_pet_state_path(@unlabeled_appearance.pet_type, + @unlabeled_appearance, next: "unlabeled-appearance") + \= #{number_with_delimiter @counts[:total]} total + = form_with method: :get, class: "rainbow-pool-filters" do |form| %fieldset %legend Filter by: