remove :cached_notifications gate
This commit is contained in:
parent
e0cc3cdd1b
commit
d01a53eb72
5 changed files with 0 additions and 42 deletions
|
@ -288,17 +288,7 @@ class Dossier < ApplicationRecord
|
|||
scope :for_procedure, -> (procedure) { includes(:user, :groupe_instructeur).where(groupe_instructeurs: { procedure: procedure }) }
|
||||
scope :for_api_v2, -> { includes(procedure: [:administrateurs], etablissement: [], individual: [], traitements: []) }
|
||||
|
||||
# todo: once we are sure with_cached_notifications does not introduce regressions, remove with_unoptimized_notifications
|
||||
# and use with_cached_notifications instead
|
||||
scope :with_notifications, -> (instructeur) do
|
||||
if Flipper.enabled?(:cached_notifications, instructeur)
|
||||
return with_cached_notifications
|
||||
else
|
||||
return with_unoptimized_notifications
|
||||
end
|
||||
end
|
||||
|
||||
scope :with_cached_notifications, -> do
|
||||
joins(:follows)
|
||||
.where('last_champ_updated_at > follows.demande_seen_at' \
|
||||
' OR groupe_instructeur_updated_at > follows.demande_seen_at' \
|
||||
|
@ -308,33 +298,6 @@ class Dossier < ApplicationRecord
|
|||
.distinct
|
||||
end
|
||||
|
||||
scope :with_unoptimized_notifications, -> do
|
||||
# This scope is meant to be composed, typically with Instructeur.followed_dossiers, which means that the :follows table is already INNER JOINed;
|
||||
# it will fail otherwise
|
||||
# rubocop:disable DS/ApplicationName
|
||||
joined_dossiers = joins('LEFT OUTER JOIN "champs" ON "champs" . "dossier_id" = "dossiers" . "id" AND "champs" . "parent_id" IS NULL AND "champs" . "private" = FALSE AND "champs"."updated_at" > "follows"."demande_seen_at"')
|
||||
.joins('LEFT OUTER JOIN "champs" "champs_privates_dossiers" ON "champs_privates_dossiers" . "dossier_id" = "dossiers" . "id" AND "champs_privates_dossiers" . "parent_id" IS NULL AND "champs_privates_dossiers" . "private" = TRUE AND "champs_privates_dossiers"."updated_at" > "follows"."annotations_privees_seen_at"')
|
||||
.joins('LEFT OUTER JOIN "avis" ON "avis" . "dossier_id" = "dossiers" . "id" AND avis.updated_at > follows.avis_seen_at')
|
||||
.joins('LEFT OUTER JOIN "commentaires" ON "commentaires" . "dossier_id" = "dossiers" . "id" and commentaires.updated_at > follows.messagerie_seen_at and "commentaires"."email" != \'contact@tps.apientreprise.fr\' AND "commentaires"."email" != \'contact@demarches-simplifiees.fr\'')
|
||||
# rubocop:enable DS/ApplicationName
|
||||
|
||||
updated_demandes = joined_dossiers
|
||||
.where('champs.updated_at > follows.demande_seen_at OR groupe_instructeur_updated_at > follows.demande_seen_at')
|
||||
|
||||
updated_annotations = joined_dossiers
|
||||
.where('champs_privates_dossiers.updated_at > follows.annotations_privees_seen_at')
|
||||
|
||||
updated_avis = joined_dossiers
|
||||
.where('avis.updated_at > follows.avis_seen_at')
|
||||
|
||||
updated_messagerie = joined_dossiers
|
||||
.where('commentaires.updated_at > follows.messagerie_seen_at')
|
||||
.where.not(commentaires: { email: OLD_CONTACT_EMAIL })
|
||||
.where.not(commentaires: { email: CONTACT_EMAIL })
|
||||
|
||||
updated_demandes.or(updated_annotations).or(updated_avis).or(updated_messagerie).distinct
|
||||
end
|
||||
|
||||
accepts_nested_attributes_for :individual
|
||||
|
||||
delegate :siret, :siren, to: :etablissement, allow_nil: true
|
||||
|
|
|
@ -887,8 +887,6 @@ describe Users::DossiersController, type: :controller do
|
|||
before do
|
||||
Timecop.freeze(now)
|
||||
sign_in(user)
|
||||
# Flipper.enable(:cached_notifications, instructeur_with_instant_message)
|
||||
# Flipper.enable(:cached_notifications, instructeur_without_instant_message)
|
||||
allow(ClamavService).to receive(:safe_file?).and_return(scan_result)
|
||||
allow(DossierMailer).to receive(:notify_new_commentaire_to_instructeur).and_return(double(deliver_later: nil))
|
||||
instructeur_with_instant_message.follow(dossier)
|
||||
|
|
|
@ -103,7 +103,6 @@ describe Dossier do
|
|||
|
||||
before do
|
||||
create(:follow, dossier: dossier, instructeur: instructeur, messagerie_seen_at: 2.hours.ago)
|
||||
Flipper.enable_actor(:cached_notifications, instructeur)
|
||||
end
|
||||
|
||||
subject { instructeur.followed_dossiers.with_notifications(instructeur) }
|
||||
|
|
|
@ -8,7 +8,6 @@ describe Instructeur, type: :model do
|
|||
|
||||
before do
|
||||
assign(procedure_2)
|
||||
Flipper.enable_actor(:cached_notifications, instructeur)
|
||||
end
|
||||
|
||||
describe 'follow' do
|
||||
|
|
|
@ -262,7 +262,6 @@ describe ProcedurePresentation do
|
|||
let!(:older_dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
||||
|
||||
before do
|
||||
Flipper.enable_actor(:cached_notifications, instructeur)
|
||||
notified_dossier.update!(last_champ_updated_at: Time.zone.local(2018, 9, 20))
|
||||
create(:follow, instructeur: instructeur, dossier: notified_dossier, demande_seen_at: Time.zone.local(2018, 9, 10))
|
||||
notified_dossier.touch(time: Time.zone.local(2018, 9, 20))
|
||||
|
|
Loading…
Reference in a new issue