integrate a mininum weight for the average dossier weight

before this commit, the average dossier weight took account only pieces
justificatives. With this commit, we add a minimum weight for other
files included in an archive like pdf_export, log operations,
attachments added to traitements. This minimum weight is set arbitrary,
from the observation of some random procedures in production
This commit is contained in:
Christophe Robillard 2021-07-06 15:00:33 +02:00
parent cedef676b0
commit bc07a875eb
2 changed files with 3 additions and 2 deletions

View file

@ -55,6 +55,7 @@ class Procedure < ApplicationRecord
MAX_DUREE_CONSERVATION = 36 MAX_DUREE_CONSERVATION = 36
MAX_DUREE_CONSERVATION_EXPORT = 3.hours MAX_DUREE_CONSERVATION_EXPORT = 3.hours
MIN_WEIGHT = 350000
has_many :revisions, -> { order(:id) }, class_name: 'ProcedureRevision', inverse_of: :procedure has_many :revisions, -> { order(:id) }, class_name: 'ProcedureRevision', inverse_of: :procedure
belongs_to :draft_revision, class_name: 'ProcedureRevision', optional: false belongs_to :draft_revision, class_name: 'ProcedureRevision', optional: false
belongs_to :published_revision, class_name: 'ProcedureRevision', optional: true belongs_to :published_revision, class_name: 'ProcedureRevision', optional: true
@ -684,7 +685,7 @@ class Procedure < ApplicationRecord
.where(type: Champs::PieceJustificativeChamp.to_s, dossier: dossiers_sample) .where(type: Champs::PieceJustificativeChamp.to_s, dossier: dossiers_sample)
.sum('active_storage_blobs.byte_size') .sum('active_storage_blobs.byte_size')
total_size / dossiers_sample.length MIN_WEIGHT + total_size / dossiers_sample.length
else else
nil nil
end end

View file

@ -1026,7 +1026,7 @@ describe Procedure do
end end
it 'estimates average dossier weight' do it 'estimates average dossier weight' do
expect(procedure.reload.average_dossier_weight).to eq 5 expect(procedure.reload.average_dossier_weight).to eq(5 + Procedure::MIN_WEIGHT)
end end
end end