mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-31 12:39:08 +01:00
Move fetching of services to controller to avoid n+1 queries
This commit is contained in:
parent
4dcc5dea55
commit
3e2b65d7b8
2 changed files with 12 additions and 9 deletions
|
@ -8,16 +8,12 @@ class InboxController < ApplicationController
|
||||||
def show
|
def show
|
||||||
find_author
|
find_author
|
||||||
find_inbox_entries
|
find_inbox_entries
|
||||||
|
check_for_empty_filter
|
||||||
if @author_user && @inbox_count.zero?
|
|
||||||
# rubocop disabled because of a false positive
|
|
||||||
flash[:info] = t(".author.info", author: @author) # rubocop:disable Rails/ActionControllerFlashBeforeRender
|
|
||||||
redirect_to inbox_path(last_id: params[:last_id])
|
|
||||||
end
|
|
||||||
|
|
||||||
@delete_id = find_delete_id
|
@delete_id = find_delete_id
|
||||||
|
@services = current_user.services
|
||||||
@disabled = true if @inbox.empty?
|
@disabled = true if @inbox.empty?
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.turbo_stream do
|
format.turbo_stream do
|
||||||
|
@ -50,6 +46,13 @@ class InboxController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def check_for_empty_filter
|
||||||
|
return unless @author_user && @inbox_count.zero?
|
||||||
|
|
||||||
|
flash[:info] = t(".author.info", author: @author)
|
||||||
|
redirect_to inbox_path(last_id: params[:last_id])
|
||||||
|
end
|
||||||
|
|
||||||
def find_author
|
def find_author
|
||||||
return if params[:author].blank?
|
return if params[:author].blank?
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,9 @@
|
||||||
= render "shared/format_link"
|
= render "shared/format_link"
|
||||||
.card-footer.d-none{ id: "ib-options-#{i.id}" }
|
.card-footer.d-none{ id: "ib-options-#{i.id}" }
|
||||||
%h4= t(".sharing.heading")
|
%h4= t(".sharing.heading")
|
||||||
- if current_user.services.count.positive?
|
- if @services.count.positive?
|
||||||
.row
|
.row
|
||||||
- current_user.services.each do |service|
|
- @services.each do |service|
|
||||||
.col-md-3.col-sm-4.col-xs-6
|
.col-md-3.col-sm-4.col-xs-6
|
||||||
%label
|
%label
|
||||||
%input{ type: "checkbox", name: "ib-share", checked: :checked, data: { ib_id: i.id, service: service.provider } }
|
%input{ type: "checkbox", name: "ib-share", checked: :checked, data: { ib_id: i.id, service: service.provider } }
|
||||||
|
|
Loading…
Reference in a new issue