remove useless snapshot
This commit is contained in:
parent
b5ed8c9b61
commit
71bcbbc440
4 changed files with 34 additions and 28 deletions
|
@ -17,7 +17,6 @@ class ExportDashboard < Administrate::BaseDashboard
|
|||
job_status: Field::Select.with_options(searchable: false, collection: -> (field) { field.resource.class.send(field.attribute.to_s.pluralize).keys }),
|
||||
key: Field::Text,
|
||||
procedure_presentation: IdField,
|
||||
procedure_presentation_snapshot: Field::String.with_options(searchable: false),
|
||||
statut: Field::Select.with_options(searchable: false, collection: -> (field) { field.resource.class.send(field.attribute.to_s.pluralize).keys }),
|
||||
time_span_type: Field::Select.with_options(searchable: false, collection: -> (field) { field.resource.class.send(field.attribute.to_s.pluralize).keys }),
|
||||
created_at: Field::DateTime.with_options(format: "%d/%m %H:%M:%S"),
|
||||
|
@ -34,7 +33,7 @@ class ExportDashboard < Administrate::BaseDashboard
|
|||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [:id, :procedure, :job_status, :format, :statut, :file, :groupe_instructeurs, :key, :procedure_presentation, :procedure_presentation_snapshot, :time_span_type, :created_at, :updated_at].freeze
|
||||
SHOW_PAGE_ATTRIBUTES = [:id, :procedure, :job_status, :format, :statut, :file, :groupe_instructeurs, :key, :procedure_presentation, :time_span_type, :created_at, :updated_at].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
class Export < ApplicationRecord
|
||||
include TransientModelsWithPurgeableJobConcern
|
||||
|
||||
self.ignored_columns += ["procedure_presentation_snapshot"]
|
||||
|
||||
MAX_DUREE_CONSERVATION_EXPORT = 32.hours
|
||||
MAX_DUREE_GENERATION = 16.hours
|
||||
|
||||
|
@ -59,7 +61,6 @@ class Export < ApplicationRecord
|
|||
|
||||
def compute
|
||||
self.dossiers_count = dossiers_for_export.count
|
||||
load_snapshot!
|
||||
|
||||
file.attach(blob.signed_id) # attaching a blob directly might run identify/virus scanner and wipe it
|
||||
end
|
||||
|
@ -94,7 +95,6 @@ class Export < ApplicationRecord
|
|||
create!(**attributes, groupe_instructeurs:,
|
||||
user_profile:,
|
||||
procedure_presentation:,
|
||||
procedure_presentation_snapshot: procedure_presentation&.snapshot,
|
||||
filtered_columns:,
|
||||
sorted_column:)
|
||||
end
|
||||
|
@ -129,12 +129,6 @@ class Export < ApplicationRecord
|
|||
|
||||
private
|
||||
|
||||
def load_snapshot!
|
||||
if procedure_presentation_snapshot.present?
|
||||
procedure_presentation.attributes = procedure_presentation_snapshot
|
||||
end
|
||||
end
|
||||
|
||||
def dossiers_for_export
|
||||
@dossiers_for_export ||= begin
|
||||
dossiers = Dossier.where(groupe_instructeur: groupe_instructeurs)
|
||||
|
|
|
@ -73,10 +73,6 @@ class ProcedurePresentation < ApplicationRecord
|
|||
nil
|
||||
end
|
||||
|
||||
def snapshot
|
||||
slice(:filters, :sort, :displayed_fields)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_type_de_champ(column)
|
||||
|
|
|
@ -154,10 +154,16 @@ RSpec.describe Export, type: :model do
|
|||
let!(:dossier_accepte) { create(:dossier, :accepte, procedure: procedure) }
|
||||
|
||||
let(:export) do
|
||||
create(:export,
|
||||
groupe_instructeurs: [procedure.groupe_instructeurs.first],
|
||||
procedure_presentation: procedure_presentation,
|
||||
statut: statut)
|
||||
groupe_instructeurs = [procedure.groupe_instructeurs.first]
|
||||
user_profile = groupe_instructeurs.first.instructeurs.first
|
||||
|
||||
Export.find_or_create_fresh_export(
|
||||
:csv,
|
||||
groupe_instructeurs,
|
||||
user_profile,
|
||||
procedure_presentation:,
|
||||
statut:
|
||||
)
|
||||
end
|
||||
|
||||
context 'without procedure_presentation or since' do
|
||||
|
@ -171,17 +177,28 @@ RSpec.describe Export, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with procedure_presentation and statut supprimes' do
|
||||
let(:statut) { 'supprimes' }
|
||||
let(:procedure_presentation) do
|
||||
create(:procedure_presentation,
|
||||
procedure: procedure,
|
||||
assign_to: procedure.groupe_instructeurs.first.assign_tos.first)
|
||||
end
|
||||
let!(:dossier_supprime) { create(:dossier, :accepte, procedure: procedure, hidden_by_administration_at: 2.days.ago) }
|
||||
context 'with procedure_presentation and statut tous and filter en_construction' do
|
||||
let(:statut) { 'tous' }
|
||||
|
||||
it 'includes supprimes' do
|
||||
expect(export.send(:dossiers_for_export)).to include(dossier_supprime)
|
||||
let(:procedure_presentation) do
|
||||
statut_column = procedure.find_column(label: 'Statut')
|
||||
en_construction_filter = FilteredColumn.new(column: statut_column, filter: 'en_construction')
|
||||
create(:procedure_presentation,
|
||||
procedure:,
|
||||
assign_to: procedure.groupe_instructeurs.first.assign_tos.first,
|
||||
tous_filters: [en_construction_filter])
|
||||
end
|
||||
|
||||
before do
|
||||
# ensure the export is generated
|
||||
export
|
||||
|
||||
# change the procedure presentation
|
||||
procedure_presentation.update(tous_filters: [])
|
||||
end
|
||||
|
||||
it 'only includes the en_construction' do
|
||||
expect(export.send(:dossiers_for_export)).to eq([dossier_en_construction])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue