Merge pull request #6259 from betagouv/optim-stat-by-weej

optimise les stats du nb de dossiers termines par semaine
This commit is contained in:
krichtof 2021-06-08 15:44:52 +02:00 committed by GitHub
commit c6b6ba96b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,7 +31,7 @@ module ProcedureStatsConcern
def stats_termines_by_week
Rails.cache.fetch("#{cache_key_with_version}/stats_termines_by_week", expires_in: 12.hours) do
now = Time.zone.now
chart_data = dossiers.joins(:traitements)
chart_data = dossiers.includes(:traitements)
.state_termine
.where(traitements: { processed_at: (now.beginning_of_week - 6.months)..now.end_of_week })