From 6fa6d4db989ff40bc0d32a0f493c14b8c616a7af Mon Sep 17 00:00:00 2001 From: IMonardez Date: Thu, 9 Jan 2025 12:38:51 -0300 Subject: [PATCH] ISSUE #448: Correction at affiliation initial date error --- db/migrate/20240524135850_create_affiliation.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/db/migrate/20240524135850_create_affiliation.rb b/db/migrate/20240524135850_create_affiliation.rb index 8802b77f..609a0073 100644 --- a/db/migrate/20240524135850_create_affiliation.rb +++ b/db/migrate/20240524135850_create_affiliation.rb @@ -40,17 +40,13 @@ def up elsif professor.institution_id == institution_id || ((end_date - start_date) <= 1.month) affiliation.update(start_date: start_date) end - # Se for a primeira versão do professor pega a data da primeira tese do professor e diminui um mês - if professor.paper_trail.previous_version.nil? - if initial_start_date.nil? - affiliation.update(start_date: start_date - 1.month) - else - affiliation.update(start_date: initial_start_date - 1.month) - end - break - end professor = professor.paper_trail.previous_version end + if initial_start_date.nil? || initial_start_date >= start_date + affiliation.update(start_date: start_date - 1.month) + elsif + affiliation.update(start_date: initial_start_date - 1.month) + end institutions << { institution_id:, start_date:, end_date: } end