From fed1f3e9216ec0021200dfd8e0289d0b5fc5567a Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 26 Feb 2019 11:39:32 +0100 Subject: [PATCH 1/3] Use query filter instead of array.reject --- app/models/procedure_presentation.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/procedure_presentation.rb b/app/models/procedure_presentation.rb index abcda68bf..bdc87b0ca 100644 --- a/app/models/procedure_presentation.rb +++ b/app/models/procedure_presentation.rb @@ -49,11 +49,11 @@ class ProcedurePresentation < ApplicationRecord explanatory_types_de_champ = [:header_section, :explication].map { |k| TypeDeChamp.type_champs.fetch(k) } fields.concat procedure.types_de_champ - .reject { |tdc| explanatory_types_de_champ.include?(tdc.type_champ) } + .where.not(type_champ: explanatory_types_de_champ) .map { |type_de_champ| field_hash(type_de_champ.libelle, 'type_de_champ', type_de_champ.id.to_s) } fields.concat procedure.types_de_champ_private - .reject { |tdc| explanatory_types_de_champ.include?(tdc.type_champ) } + .where.not(type_champ: explanatory_types_de_champ) .map { |type_de_champ| field_hash(type_de_champ.libelle, 'type_de_champ_private', type_de_champ.id.to_s) } fields From ff1f59a882942221ebcd049b05ea6868d548f4f2 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 26 Feb 2019 12:02:38 +0100 Subject: [PATCH 2/3] Add index Procedure_id on TypesDeChamp --- ...0190226105641_add_procedure_id_index_to_types_de_champ.rb | 5 +++++ db/schema.rb | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20190226105641_add_procedure_id_index_to_types_de_champ.rb diff --git a/db/migrate/20190226105641_add_procedure_id_index_to_types_de_champ.rb b/db/migrate/20190226105641_add_procedure_id_index_to_types_de_champ.rb new file mode 100644 index 000000000..52fe10271 --- /dev/null +++ b/db/migrate/20190226105641_add_procedure_id_index_to_types_de_champ.rb @@ -0,0 +1,5 @@ +class AddProcedureIdIndexToTypesDeChamp < ActiveRecord::Migration[5.2] + def change + add_index :types_de_champ, :procedure_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 05ee04c74..2220f2215 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_02_13_144145) do +ActiveRecord::Schema.define(version: 2019_02_26_105641) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -545,6 +545,7 @@ ActiveRecord::Schema.define(version: 2019_02_13_144145) do t.bigint "parent_id" t.index ["parent_id"], name: "index_types_de_champ_on_parent_id" t.index ["private"], name: "index_types_de_champ_on_private" + t.index ["procedure_id"], name: "index_types_de_champ_on_procedure_id" t.index ["stable_id"], name: "index_types_de_champ_on_stable_id" end From b3c0a261d77287ebb15d4fb06fdcd434487aa228 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 25 Feb 2019 14:52:52 +0100 Subject: [PATCH 3/3] Fix Sentry 238 --- app/uploaders/procedure_logo_uploader.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/uploaders/procedure_logo_uploader.rb b/app/uploaders/procedure_logo_uploader.rb index c38970ac0..6538230b6 100644 --- a/app/uploaders/procedure_logo_uploader.rb +++ b/app/uploaders/procedure_logo_uploader.rb @@ -28,9 +28,9 @@ class ProcedureLogoUploader < BaseUploader if file.present? if original_filename.present? || model.logo_secure_token if Flipflop.remote_storage? - filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}" + filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension&.downcase}" else - filename = "logo-#{secure_token}.#{file.extension.downcase}" + filename = "logo-#{secure_token}.#{file.extension&.downcase}" end end filename