Add extra support info to Rainbow Pool pet types
Easy-to-notice hints for which pet types need more labeling!
This commit is contained in:
parent
dfca88bed3
commit
f87f4e61b3
6 changed files with 54 additions and 4 deletions
|
@ -55,6 +55,9 @@
|
||||||
position: relative
|
position: relative
|
||||||
z-index: 1
|
z-index: 1
|
||||||
|
|
||||||
|
.info
|
||||||
|
font-size: .85em
|
||||||
|
|
||||||
.rainbow-pool-pagination
|
.rainbow-pool-pagination
|
||||||
margin-block: .5em
|
margin-block: .5em
|
||||||
display: flex
|
display: flex
|
||||||
|
|
|
@ -13,7 +13,7 @@ class PetTypesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
@pet_types = PetType.
|
@pet_types = PetType.
|
||||||
includes(:color, :species).
|
includes(:color, :species, :pet_states).
|
||||||
order(created_at: :desc).
|
order(created_at: :desc).
|
||||||
paginate(page: params[:page], per_page: 30)
|
paginate(page: params[:page], per_page: 30)
|
||||||
|
|
||||||
|
@ -59,11 +59,12 @@ class PetTypesController < ApplicationController
|
||||||
#
|
#
|
||||||
# If no main poses are available, then we just make all the poses
|
# If no main poses are available, then we just make all the poses
|
||||||
# "canonical", and show the whole mish-mash!
|
# "canonical", and show the whole mish-mash!
|
||||||
MAIN_POSES = %w(HAPPY_FEM HAPPY_MASC SAD_FEM SAD_MASC SICK_FEM SICK_MASC)
|
|
||||||
def group_pet_states(pet_states)
|
def group_pet_states(pet_states)
|
||||||
pose_groups = pet_states.emotion_order.group_by(&:pose)
|
pose_groups = pet_states.emotion_order.group_by(&:pose)
|
||||||
main_groups = pose_groups.select { |k| MAIN_POSES.include?(k) }.values
|
main_groups =
|
||||||
other_groups = pose_groups.reject { |k| MAIN_POSES.include?(k) }.values
|
pose_groups.select { |k| PetState::MAIN_POSES.include?(k) }.values
|
||||||
|
other_groups =
|
||||||
|
pose_groups.reject { |k| PetState::MAIN_POSES.include?(k) }.values
|
||||||
|
|
||||||
if main_groups.empty?
|
if main_groups.empty?
|
||||||
return {canonical: other_groups.flatten(1).sort_by(&:pose), other: []}
|
return {canonical: other_groups.flatten(1).sort_by(&:pose), other: []}
|
||||||
|
|
16
app/helpers/pet_types_helper.rb
Normal file
16
app/helpers/pet_types_helper.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
module PetTypesHelper
|
||||||
|
def moon_progress(num, total)
|
||||||
|
nearest_quarter = (4.0 * num / total).round / 4.0
|
||||||
|
if nearest_quarter >= 1
|
||||||
|
"🌕️"
|
||||||
|
elsif nearest_quarter >= 0.75
|
||||||
|
"🌔"
|
||||||
|
elsif nearest_quarter >= 0.5
|
||||||
|
"🌓"
|
||||||
|
elsif nearest_quarter >= 0.25
|
||||||
|
"🌒"
|
||||||
|
else
|
||||||
|
"🌑"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,5 +1,7 @@
|
||||||
class PetState < ApplicationRecord
|
class PetState < ApplicationRecord
|
||||||
SwfAssetType = 'biology'
|
SwfAssetType = 'biology'
|
||||||
|
|
||||||
|
MAIN_POSES = %w(HAPPY_FEM HAPPY_MASC SAD_FEM SAD_MASC SICK_FEM SICK_MASC)
|
||||||
|
|
||||||
has_many :contributions, :as => :contributed,
|
has_many :contributions, :as => :contributed,
|
||||||
:inverse_of => :contributed # in case of duplicates being merged
|
:inverse_of => :contributed # in case of duplicates being merged
|
||||||
|
|
|
@ -116,6 +116,23 @@ class PetType < ApplicationRecord
|
||||||
"#{color.human_name}-#{species.human_name}"
|
"#{color.human_name}-#{species.human_name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fully_labeled?
|
||||||
|
num_missing_poses == 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def num_poses
|
||||||
|
all_poses = pet_states.map(&:pose)
|
||||||
|
PetState::MAIN_POSES.count { |pose| all_poses.include? pose }
|
||||||
|
end
|
||||||
|
|
||||||
|
def num_missing_poses
|
||||||
|
PetState::MAIN_POSES.count - num_poses
|
||||||
|
end
|
||||||
|
|
||||||
|
def num_unlabeled_states
|
||||||
|
pet_states.count { |ps| ps.pose == "UNKNOWN" }
|
||||||
|
end
|
||||||
|
|
||||||
def self.basic_body_ids
|
def self.basic_body_ids
|
||||||
PetType.basic.distinct.pluck(:body_id)
|
PetType.basic.distinct.pluck(:body_id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,3 +2,14 @@
|
||||||
= link_to pet_type do
|
= link_to pet_type do
|
||||||
= pet_type_image pet_type, :happy, :thumb, class: "preview"
|
= pet_type_image pet_type, :happy, :thumb, class: "preview"
|
||||||
.name= pet_type.human_name
|
.name= pet_type.human_name
|
||||||
|
- if support_staff?
|
||||||
|
.info
|
||||||
|
- if pet_type.num_unlabeled_states > 0
|
||||||
|
%span{title: "Unlabeled states"}
|
||||||
|
❓️ #{pet_type.num_unlabeled_states} +
|
||||||
|
%span{title: "Labeled main poses"}
|
||||||
|
- if pet_type.fully_labeled?
|
||||||
|
✅ #{pet_type.num_poses}/#{pet_type.num_poses}
|
||||||
|
- else
|
||||||
|
= moon_progress pet_type.num_poses, pet_type.num_poses + pet_type.num_missing_poses
|
||||||
|
#{pet_type.num_poses}/#{pet_type.num_poses + pet_type.num_missing_poses}
|
||||||
|
|
Loading…
Reference in a new issue