return artifact enum values as integers

This commit is contained in:
Justin Edmund 2025-12-13 20:09:34 -08:00
parent 0a069c0324
commit 4db5f4224e
2 changed files with 16 additions and 4 deletions

View file

@ -10,7 +10,12 @@ module Api
}
end
fields :granblue_id, :proficiency, :rarity
fields :granblue_id, :rarity
# Return proficiency as integer (nil for quirk artifacts)
field :proficiency do |a|
a.proficiency_before_type_cast
end
field :release_date, if: ->(_field, a, _options) { a.release_date.present? }
end

View file

@ -5,10 +5,17 @@ module Api
class CollectionArtifactBlueprint < ApiBlueprint
identifier :id
fields :element, :level, :nickname, :reroll_slot, :created_at, :updated_at
fields :level, :nickname, :reroll_slot, :created_at, :updated_at
# Proficiency is only present on quirk artifacts
field :proficiency, if: ->(_field, obj, _options) { obj.proficiency.present? }
# Return element as integer
field :element do |obj|
obj.element_before_type_cast
end
# Proficiency is only present on quirk artifacts, return as integer
field :proficiency, if: ->(_field, obj, _options) { obj.proficiency.present? } do |obj|
obj.proficiency_before_type_cast
end
field :skills do |obj|
[obj.skill1, obj.skill2, obj.skill3, obj.skill4].map do |skill|