1
0
Fork 0

Merge branch 'atomaka/bugfix/api-n+1' into 'master'

Fix N+1 on API

Rarity
Type
Leader Skill
Passive Skill
Super Attack
Awaken Type
Dokkan Card
HP, ATK, Def
Links (one query per)

N+11-16 depending on link count * 224 cards = > 3000 queries.  WHOOPS.

Let's drop that down to 13 queries total.

See merge request !16
This commit is contained in:
Andrew Tomaka 2015-11-03 12:09:23 -05:00
commit 44b4f7314d
1 changed files with 6 additions and 1 deletions

View File

@ -1,7 +1,12 @@
class Api::V1::CardsController < Api::V1::BaseController
before_action :set_card, only: [:show]
def index
render json: Card.all, root: false
@cards = Card.includes(:character, :rarity, :type, :leader_skill,
:passive_skill, :super_attack, :awaken_type,
:dokkan_card, :hp_stat, :atk_stat, :def_stat,
:links)
render json: @cards, root: false
end
def show