demarches-normaliennes/app/services
Pierre de La Morinerie 0e35bc609d notifications: don't preload dossiers on instructeurs
This request currently times out almost every night in production.

It's because although Instructeurs are loaded in batches (default batch
size is 1000), loading all dossiers for 1000 instructeurs is slow.

Turns out the code executed after this query to compute notifications
doesn't even use these dossiers. Indeed it is faster not to preload
them: both the initial query and the total treatment time are shorter.

Here's a quick benchmark made locally (but using production data):

- Before this commit:

	Benchmark.measure { pp Instructeur.includes(assign_to: { procedure: :dossiers }).where(assign_tos: { daily_email_notifications_enabled: true }).limit(100).m
ap(&:email_notification_data) }

Only the initial query : 35s
Total time : 97s

- Without preloading dossiers:

	Benchmark.measure { pp Instructeur.includes(assign_to: :procedure).where(assign_tos: { daily_email_notifications_enabled: true }).limit(100).m
ap(&:email_notification_data) }

Only the initial query : 0.08s (400x faster)
Total time : 29s (3,3x faster)

Plus it doesn't timeout, of course.
2021-12-09 12:10:00 +01:00
..
administrateur_usage_statistics_service.rb Use revision instead of groupe instructeur as dossier procedure link 2021-03-09 14:47:23 +01:00
agent_connect_service.rb manage AgentConnect callback 2021-11-23 14:17:59 +01:00
api_entreprise_service.rb zeitwerk: Api -> API 2021-02-09 13:07:30 +01:00
bill_signature_service.rb Bug with time zone: Time.zone.today looses time_zone and may breaks database comparisons 2019-12-11 17:34:10 +01:00
browser_support.rb Update browser gem 2020-03-17 11:25:20 +01:00
clamav_service.rb If ClamavService fails then raise an error 2019-02-05 17:58:41 +01:00
commentaire_service.rb Remove the link between commentaire and user 2021-04-22 15:10:47 +01:00
countries_service.rb fix(i18n): add Kosovo to countries list 2021-09-08 12:11:25 +02:00
dossier_projection_service.rb modify dossier projection service 2021-11-26 09:45:13 +01:00
dossier_search_service.rb avoid serializing long id list in case of huge procedure, search on it before 2021-05-20 12:08:04 +02:00
encryption_service.rb Feat (API Particulier): new encryption service 2021-07-30 11:18:44 +02:00
expired_dossiers_deletion_service.rb fix(spec/lint/review): lint and fix spec of previous commits, also fix based on tchak feedback 2021-12-06 07:05:17 +01:00
france_connect_service.rb disable france connect authentication for admin and instructeurs 2021-02-10 18:13:47 +01:00
geojson_service.rb Fix geo length computations 2020-10-01 15:09:38 +02:00
instructeurs_import_service.rb fix import service 2021-06-21 14:11:05 +02:00
ip_service.rb Refactor (Rubocop): replace map{ … }.compact by filter_map 2021-06-11 15:38:09 +02:00
notification_service.rb notifications: don't preload dossiers on instructeurs 2021-12-09 12:10:00 +01:00
pieces_justificatives_service.rb modify pj service 2021-10-05 15:00:21 +02:00
pipedrive_service.rb Add nb_of_dossiers by years and deadline to PipeDrive Person 2019-06-04 16:55:11 +02:00
procedure_archive_service.rb fix(virus scan): prevent virus scan on archives and signatures uploads 2021-09-07 14:21:48 +02:00
procedure_export_service.rb fix(revisions): fix repetitions export with revisions 2021-11-03 18:20:48 +01:00
serializer_service.rb GraphQL byte_size should be BigInt 2021-06-03 10:53:17 +02:00
staging_auth_service.rb [ENV] Basic auth config 2018-08-23 15:55:32 +02:00
zxcvbn_service.rb services: cache zxcvbn dictionaries per-thread 2021-10-25 12:04:56 +02:00