Merge pull request #7848 from betagouv/perf_on_invite

perf: optimise la liste déroulante concernant les invités
This commit is contained in:
LeSim 2022-10-06 17:39:07 +02:00 committed by GitHub
commit 183506810b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 5 deletions

View file

@ -1,9 +1,10 @@
- invites = dossier.invites.load
.dropdown.invite-user-action{ data: { controller: 'menu-button', popover: 'true' } } .dropdown.invite-user-action{ data: { controller: 'menu-button', popover: 'true' } }
%button.button.dropdown-button{ data: { menu_button_target: 'button' } } %button.button.dropdown-button{ data: { menu_button_target: 'button' } }
%span.icon.person %span.icon.person
- if dossier.invites.count > 0 - if invites.size > 0
= t('views.invites.dropdown.view_invited_people') = t('views.invites.dropdown.view_invited_people')
%span.badge= dossier.invites.count %span.badge= invites.size
- else - else
- if dossier.read_only? - if dossier.read_only?
= t('views.invites.dropdown.invite_to_view') = t('views.invites.dropdown.invite_to_view')
@ -11,4 +12,4 @@
= t('views.invites.dropdown.invite_to_edit') = t('views.invites.dropdown.invite_to_edit')
#invite-content.dropdown-content.fade-in-down{ data: { menu_button_target: 'menu' } } #invite-content.dropdown-content.fade-in-down{ data: { menu_button_target: 'menu' } }
= render partial: "invites/form", locals: { dossier: dossier } = render partial: "invites/form", locals: { dossier: dossier, invites: invites }

View file

@ -1,8 +1,8 @@
#invites-form #invites-form
- if dossier.invites.present? - if invites.present?
%h4= t('views.invites.form.invite_to_participate') %h4= t('views.invites.form.invite_to_participate')
%ul %ul
- dossier.invites.each do |invite| - invites.each do |invite|
%li %li
= invite.email = invite.email
%small{ 'data-turbo': 'true' } %small{ 'data-turbo': 'true' }

View file

@ -0,0 +1,7 @@
class AddIndexOnDossierIdToInvites < ActiveRecord::Migration[6.1]
include Database::MigrationHelpers
disable_ddl_transaction!
def up
add_concurrent_index :invites, [:dossier_id]
end
end

View file

@ -562,6 +562,7 @@ ActiveRecord::Schema.define(version: 2022_10_05_145646) do
t.text "message" t.text "message"
t.datetime "updated_at" t.datetime "updated_at"
t.integer "user_id" t.integer "user_id"
t.index ["dossier_id"], name: "index_invites_on_dossier_id"
t.index ["email", "dossier_id"], name: "index_invites_on_email_and_dossier_id", unique: true t.index ["email", "dossier_id"], name: "index_invites_on_email_and_dossier_id", unique: true
end end