From 2f2f1e13211643edf40e93764083e4f07b02b589 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 31 Oct 2018 10:29:03 +0100 Subject: [PATCH 1/2] Let the API return times in UTC for now --- app/serializers/commentaire_serializer.rb | 4 ++++ app/serializers/dossier_serializer.rb | 16 ++++++++++++++-- app/serializers/dossiers_serializer.rb | 6 +++++- .../piece_justificative_serializer.rb | 4 ++++ app/serializers/procedure_serializer.rb | 4 ++++ .../api/v1/dossiers_controller_spec.rb | 10 +++++----- 6 files changed, 36 insertions(+), 8 deletions(-) diff --git a/app/serializers/commentaire_serializer.rb b/app/serializers/commentaire_serializer.rb index 19360bfdf..3cc79c8a2 100644 --- a/app/serializers/commentaire_serializer.rb +++ b/app/serializers/commentaire_serializer.rb @@ -4,6 +4,10 @@ class CommentaireSerializer < ActiveModel::Serializer :created_at, :attachment + def created_at + object.created_at&.in_time_zone('UTC') + end + def attachment object.file_url end diff --git a/app/serializers/dossier_serializer.rb b/app/serializers/dossier_serializer.rb index a35e5ba57..0acd0ed29 100644 --- a/app/serializers/dossier_serializer.rb +++ b/app/serializers/dossier_serializer.rb @@ -50,17 +50,29 @@ class DossierSerializer < ActiveModel::Serializer end def initiated_at - object.en_construction_at + object.en_construction_at&.in_time_zone('UTC') end def received_at - object.en_instruction_at + object.en_instruction_at&.in_time_zone('UTC') end def instructeurs object.followers_gestionnaires.pluck(:email) end + def created_at + object.created_at&.in_time_zone('UTC') + end + + def updated_at + object.updated_at&.in_time_zone('UTC') + end + + def processed_at + object.processed_at&.in_time_zone('UTC') + end + private def user_geometry(dossier) diff --git a/app/serializers/dossiers_serializer.rb b/app/serializers/dossiers_serializer.rb index a1c225229..6751e5c53 100644 --- a/app/serializers/dossiers_serializer.rb +++ b/app/serializers/dossiers_serializer.rb @@ -4,8 +4,12 @@ class DossiersSerializer < ActiveModel::Serializer :initiated_at, :state + def updated_at + object.updated_at&.in_time_zone('UTC') + end + def initiated_at - object.en_construction_at + object.en_construction_at&.in_time_zone('UTC') end def state diff --git a/app/serializers/piece_justificative_serializer.rb b/app/serializers/piece_justificative_serializer.rb index fdcf1d2c9..0a7a7a724 100644 --- a/app/serializers/piece_justificative_serializer.rb +++ b/app/serializers/piece_justificative_serializer.rb @@ -4,4 +4,8 @@ class PieceJustificativeSerializer < ActiveModel::Serializer :content_url has_one :user + + def created_at + object.created_at&.in_time_zone('UTC') + end end diff --git a/app/serializers/procedure_serializer.rb b/app/serializers/procedure_serializer.rb index bd5605a6c..d1a7a491c 100644 --- a/app/serializers/procedure_serializer.rb +++ b/app/serializers/procedure_serializer.rb @@ -18,6 +18,10 @@ class ProcedureSerializer < ActiveModel::Serializer has_many :types_de_champ_private, serializer: TypeDeChampSerializer has_many :types_de_piece_justificative, serializer: TypeDePieceJustificativeSerializer + def archived_at + object.archived_at&.in_time_zone('UTC') + end + def link if object.path.present? if object.brouillon_avec_lien? diff --git a/spec/controllers/api/v1/dossiers_controller_spec.rb b/spec/controllers/api/v1/dossiers_controller_spec.rb index 6873f031c..47ced3e71 100644 --- a/spec/controllers/api/v1/dossiers_controller_spec.rb +++ b/spec/controllers/api/v1/dossiers_controller_spec.rb @@ -75,8 +75,8 @@ describe API::V1::DossiersController do describe 'dossier' do subject { super().first } it { expect(subject[:id]).to eq(dossier.id) } - it { expect(subject[:updated_at]).to eq("2008-09-01T10:05:00.000+02:00") } - it { expect(subject[:initiated_at]).to eq("2008-09-01T10:06:00.000+02:00") } + it { expect(subject[:updated_at]).to eq("2008-09-01T08:05:00.000Z") } + it { expect(subject[:initiated_at]).to eq("2008-09-01T08:06:00.000Z") } it { expect(subject[:state]).to eq("initiated") } it { expect(subject.keys.size).to eq(4) } end @@ -148,8 +148,8 @@ describe API::V1::DossiersController do it { expect(subject[:id]).to eq(dossier.id) } it { expect(subject[:state]).to eq(dossier.state) } - it { expect(subject[:created_at]).to eq('2008-09-01T10:05:00.000+02:00') } - it { expect(subject[:updated_at]).to eq('2008-09-01T10:05:00.000+02:00') } + it { expect(subject[:created_at]).to eq('2008-09-01T08:05:00.000Z') } + it { expect(subject[:updated_at]).to eq('2008-09-01T08:05:00.000Z') } it { expect(subject[:archived]).to eq(dossier.archived) } it { expect(subject.keys).to match_array(field_list) } @@ -337,7 +337,7 @@ describe API::V1::DossiersController do it { expect(subject.size).to eq 2 } it { expect(subject.first[:body]).to eq 'plop' } - it { expect(subject.first[:created_at]).to eq '2016-03-14T14:00:00.000+01:00' } + it { expect(subject.first[:created_at]).to eq '2016-03-14T13:00:00.000Z' } it { expect(subject.first[:email]).to eq 'plop@plip.com' } end From 3418419771282c7a57d9b7ed2305e3685257d23a Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 31 Oct 2018 11:51:15 +0100 Subject: [PATCH 2/2] Remove path from archived procedures --- ...181031104615_remove_path_from_archived_procedures.rake | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 lib/tasks/deployment/20181031104615_remove_path_from_archived_procedures.rake diff --git a/lib/tasks/deployment/20181031104615_remove_path_from_archived_procedures.rake b/lib/tasks/deployment/20181031104615_remove_path_from_archived_procedures.rake new file mode 100644 index 000000000..f3e1a0ccb --- /dev/null +++ b/lib/tasks/deployment/20181031104615_remove_path_from_archived_procedures.rake @@ -0,0 +1,8 @@ +namespace :after_party do + desc 'Deployment task: remove_path_from_archived_procedures' + task remove_path_from_archived_procedures: :environment do + Procedure.archivees.where.not(path: nil).update_all(path: nil) + + AfterParty::TaskRecord.create version: '20181031104615' + end +end