about summary refs log tree commit diff stats
path: root/app/controllers
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-01-13 16:01:51 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-01-13 16:01:51 -0500
commit7e4b9ea0c23eb660ab36a6114a7a3046d8f1c5f6 (patch)
treed2e020ca045ce3d6f28a6d912bbc343db03265d2 /app/controllers
parentd91e1d9a9ee98cc364bc62a4dd156500a189b99a (diff)
downloadpokeviewer-7e4b9ea0c23eb660ab36a6114a7a3046d8f1c5f6.tar.gz
pokeviewer-7e4b9ea0c23eb660ab36a6114a7a3046d8f1c5f6.tar.bz2
pokeviewer-7e4b9ea0c23eb660ab36a6114a7a3046d8f1c5f6.zip
Moved species from Pokémon to revision
The migration will set all of the revisions of each Pokémon to have the species that that Pokémon was set to. If reversed, the migration sets the Pokémon's species to the first revision's species, which mimics the behavior of the engine from before this change, but do note that running the migration backwards like this can lose data.

This change slightly affects the loading time of the front page. See #2.

refs #3
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/pokeviewer/pokemon_controller.rb8
1 files changed, 3 insertions, 5 deletions
diff --git a/app/controllers/pokeviewer/pokemon_controller.rb b/app/controllers/pokeviewer/pokemon_controller.rb index 49a743c..7a1b9f9 100644 --- a/app/controllers/pokeviewer/pokemon_controller.rb +++ b/app/controllers/pokeviewer/pokemon_controller.rb
@@ -10,9 +10,7 @@ module Pokeviewer
10 order(slot: :asc). 10 order(slot: :asc).
11 order("pokeviewer_revisions.sequential_id DESC"). 11 order("pokeviewer_revisions.sequential_id DESC").
12 group("pokeviewer_pokemon.uuid"). 12 group("pokeviewer_pokemon.uuid").
13 select(:box, :slot, :uuid, :trainer_id, :species_id). 13 includes(:revisions).
14 select(:ot_gender, :ot_name, :unown_letter).
15 select("pokeviewer_revisions.nickname AS nickname").
16 chunk do |p| 14 chunk do |p|
17 if p.trainer_id.nil? 15 if p.trainer_id.nil?
18 -1 16 -1
@@ -71,8 +69,8 @@ module Pokeviewer
71 69
72 def show 70 def show
73 @pokemon = Pokemon.includes( 71 @pokemon = Pokemon.includes(
74 :trainer, :species, :location, 72 :trainer, :location,
75 revisions: [:item, :move_1, :move_2, :move_3, :move_4] 73 revisions: [:species, :item, :move_1, :move_2, :move_3, :move_4]
76 ).find_by_uuid! params[:id] 74 ).find_by_uuid! params[:id]
77 end 75 end
78 end 76 end