Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kill n+1 queries and fix tag links #22

Merged
merged 2 commits into from
Nov 18, 2016
Merged

Conversation

eisuke
Copy link
Member

@eisuke eisuke commented Nov 17, 2016

No description provided.

Copy link

@adorechic adorechic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems ci has broken.. does the example randomly fails?

@@ -2,7 +2,7 @@ class Kuroko2::JobDefinitionsController < Kuroko2::ApplicationController
before_action :set_definition, only: [:show, :edit, :update, :destroy]

def index
rel = Kuroko2::JobDefinition
rel = Kuroko2::JobDefinition.joins(:admins).includes(:tags, :job_instances, :job_schedules, :admins)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you join admins not only including it? (I don't know about table structures)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The admins is a has_many :through association. it do not work only includes.

@@ -21,7 +21,7 @@
td= labeled_status(definition.job_instances.take)
td
- definition.tags.each do |tag|
=link_to tag.name, root_path('tag': [tag.name]), class: 'label label-default spacer-right-3'
=link_to tag.name, { 'tag': [tag.name] }, class: 'label label-default spacer-right-3'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't you use named routes path?

Copy link
Member Author

@eisuke eisuke Nov 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this partial view used in dashboards and user details pages (/users/:id).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ic, this view is used both of dashboard and user pages, and you want to link to each of them.

btw, { tag: [tag.name] }

@adorechic
Copy link

LGTM

@eisuke eisuke merged commit 71583c6 into cookpad:master Nov 18, 2016
@eisuke eisuke deleted the n_plus_one branch November 18, 2016 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants