Hotfix so weapon key search translates ints to arrays (#140)
This commit is contained in:
parent
10901a74da
commit
d465b87da6
2 changed files with 11 additions and 6 deletions
1
.env
Normal file
1
.env
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
RAILS_LOG_TO_STDOUT=true
|
||||||
|
|
@ -5,14 +5,18 @@ module Api
|
||||||
class WeaponKeysController < Api::V1::ApiController
|
class WeaponKeysController < Api::V1::ApiController
|
||||||
def all
|
def all
|
||||||
conditions = {}.tap do |hash|
|
conditions = {}.tap do |hash|
|
||||||
hash[:series] = request.params['series'] unless request.params['series'].blank?
|
hash[:series] = request.params['series'].to_i unless request.params['series'].blank?
|
||||||
hash[:slot] = request.params['slot'] unless request.params['slot'].blank?
|
hash[:slot] = request.params['slot'].to_i unless request.params['slot'].blank?
|
||||||
hash[:group] = request.params['group'] unless request.params['group'].blank?
|
hash[:group] = request.params['group'].to_i unless request.params['group'].blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
render json: WeaponKeyBlueprint.render(
|
# Build the query based on the conditions
|
||||||
WeaponKey.where(conditions)
|
weapon_keys = WeaponKey.all
|
||||||
)
|
weapon_keys = weapon_keys.where('? = ANY(series)', conditions[:series]) if conditions.key?(:series)
|
||||||
|
weapon_keys = weapon_keys.where(slot: conditions[:slot]) if conditions.key?(:slot)
|
||||||
|
weapon_keys = weapon_keys.where(group: conditions[:group]) if conditions.key?(:group)
|
||||||
|
|
||||||
|
render json: WeaponKeyBlueprint.render(weapon_keys)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue