Add additional eager loading annotations

This commit is contained in:
Patrick Gansterer 2019-10-30 11:53:44 +01:00
parent 39aff78f11
commit 1550eedb5a
6 changed files with 9 additions and 9 deletions

View File

@ -3,7 +3,7 @@ class Admin::FinancesController < Admin::BaseController
def index
@bank_accounts = BankAccount.order('name')
@financial_transaction_classes = FinancialTransactionClass.order('name ASC')
@financial_transaction_classes = FinancialTransactionClass.includes(:financial_transaction_types).order('name ASC')
end
def update_bank_accounts
@ -12,7 +12,7 @@ class Admin::FinancesController < Admin::BaseController
end
def update_transaction_types
@financial_transaction_classes = FinancialTransactionClass.order('name ASC')
@financial_transaction_classes = FinancialTransactionClass.includes(:financial_transaction_types).order('name ASC')
render :layout => false
end

View File

@ -17,7 +17,7 @@ class Finance::BankTransactionsController < ApplicationController
end
@bank_account = BankAccount.find(params[:bank_account_id])
@bank_transactions = @bank_account.bank_transactions.order(sort)
@bank_transactions = @bank_account.bank_transactions.order(sort).includes(:financial_link)
@bank_transactions = @bank_transactions.where('reference LIKE ? OR text LIKE ?', "%#{params[:query]}%", "%#{params[:query]}%") unless params[:query].nil?
@bank_transactions = @bank_transactions.page(params[:page]).per(@per_page)
end

View File

@ -22,7 +22,7 @@ class Finance::FinancialLinksController < Finance::BaseController
remove_path: remove_financial_transaction_finance_link_path(@financial_link, ft)
}
end
@items += @financial_link.invoices.map do |invoice|
@items += @financial_link.invoices.includes(:supplier).map do |invoice|
{
date: invoice.date || invoice.created_at,
type: t('activerecord.models.invoice'),
@ -61,7 +61,7 @@ class Finance::FinancialLinksController < Finance::BaseController
end
def index_financial_transaction
@financial_transactions = FinancialTransaction.without_financial_link
@financial_transactions = FinancialTransaction.without_financial_link.includes(:financial_transaction_type, :ordergroup)
end
def add_financial_transaction
@ -77,7 +77,7 @@ class Finance::FinancialLinksController < Finance::BaseController
end
def index_invoice
@invoices = Invoice.without_financial_link
@invoices = Invoice.without_financial_link.includes(:supplier)
end
def add_invoice

View File

@ -1,7 +1,7 @@
- title t('.title')
- for supplier in @suppliers
- invoices = supplier.invoices.unpaid
- invoices = supplier.invoices
- if invoices.any?
%h3= supplier.name
- invoices_sum = 0

View File

@ -73,7 +73,7 @@
- FinancialTransactionClass.sorted.each do |fc|
%th
= fc.display
- for ft in current_user.ordergroup.financial_transactions.limit(5).order('created_on DESC')
- for ft in current_user.ordergroup.financial_transactions.includes(:financial_transaction_type, :user).limit(5).order('created_on DESC')
%tr
%td= format_time(ft.created_on)
%td= h(show_user(ft.user))

View File

@ -3,5 +3,5 @@
- unless Message.readable_for(current_user).empty?
%section#messages
%h2= t '.messages.title'
= render 'messages/messages', messages: Message.readable_for(current_user).order('created_at DESC').limit(5), pagination: false
= render 'messages/messages', messages: Message.readable_for(current_user).includes(:sender).order('created_at DESC').limit(5), pagination: false
%p= raw t '.messages.view_all.text', messages: link_to(t('.messages.view_all.messages'), messages_path), threads: link_to(t('.messages.view_all.threads'), message_threads_path)