about summary refs log tree commit diff stats
path: root/app/views
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-10-03 22:49:19 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-10-03 22:49:19 -0400
commit353b170392892a1f9bdde74550112b5131c99fd2 (patch)
tree46305a7d5fc40c4a70a7fd7615a0e549730605ec /app/views
parent4bc96847f621c4cb3940fe99b3b4b67b20596189 (diff)
downloadpokeviewer-353b170392892a1f9bdde74550112b5131c99fd2.tar.gz
pokeviewer-353b170392892a1f9bdde74550112b5131c99fd2.tar.bz2
pokeviewer-353b170392892a1f9bdde74550112b5131c99fd2.zip
Optimized front page queries
Reduced the number of queries that the front page runs to 2 queries
total: one to get trainer data, and one to get the Pokémon. The latter
query selects only the necessary columns, notably ignoring basically
everything from the revisions join other than the nickname of the most
recent revision. The controller then does the work of chunking the
Pokémon into party/boxes, and then into trainers/unaccounted.

refs #2
Diffstat (limited to 'app/views')
-rw-r--r--app/views/pokeviewer/pokemon/index.html.haml12
1 files changed, 6 insertions, 6 deletions
diff --git a/app/views/pokeviewer/pokemon/index.html.haml b/app/views/pokeviewer/pokemon/index.html.haml index 0be3edd..e1793dc 100644 --- a/app/views/pokeviewer/pokemon/index.html.haml +++ b/app/views/pokeviewer/pokemon/index.html.haml
@@ -1,4 +1,4 @@
1- @trainers.each do |trainer| 1- @trainers.each do |trainer, party, boxes|
2 .trainer 2 .trainer
3 .trainer-info{ class: trainer.game } 3 .trainer-info{ class: trainer.game }
4 %h2= trainer.name 4 %h2= trainer.name
@@ -6,11 +6,11 @@
6 .pc-boxes 6 .pc-boxes
7 %ul.party.pc-box 7 %ul.party.pc-box
8 %h3 Party 8 %h3 Party
9 - trainer.party.each do |p| 9 - party.each do |p|
10 %li 10 %li
11 %span.party-icon= image_tag p.icon_path 11 %span.party-icon= image_tag p.icon_path
12 %span.party-name= link_to p.revisions.last.nickname, p 12 %span.party-name= link_to p.nickname, p
13 - trainer.boxes.each do |box| 13 - boxes.each do |box|
14 .pc-box 14 .pc-box
15 %h3= box[:name] 15 %h3= box[:name]
16 %table.pc-contents 16 %table.pc-contents
@@ -23,7 +23,7 @@
23 - else 23 - else
24 = link_to image_tag(p.icon_path), p 24 = link_to image_tag(p.icon_path), p
25 .pc-data.pkv-hover 25 .pc-data.pkv-hover
26 .pc-data-name= p.revisions.last.nickname 26 .pc-data-name= p.nickname
27 .pc-data-ot 27 .pc-data-ot
28 OT/ 28 OT/
29 %span{ class: p.ot_gender }>= p.ot_name 29 %span{ class: p.ot_gender }>= p.ot_name
@@ -36,7 +36,7 @@
36 %li.pc-pokemon.pkv-has-hover 36 %li.pc-pokemon.pkv-has-hover
37 = link_to image_tag(p.icon_path), p 37 = link_to image_tag(p.icon_path), p
38 .pc-data.pkv-hover 38 .pc-data.pkv-hover
39 .pc-data-name= p.revisions.last.nickname 39 .pc-data-name= p.nickname
40 .pc-data-ot 40 .pc-data-ot
41 OT/ 41 OT/
42 %span{ class: p.ot_gender }>= p.ot_name 42 %span{ class: p.ot_gender }>= p.ot_name