Skip to content

Commit

Permalink
ISSUE #448: Correction at affiliation initial date error
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorMonardez committed Jan 9, 2025
1 parent a69b2ae commit a84b22d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions db/migrate/20240524135850_create_affiliation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ def up
t.timestamps
end
Professor.where.not(institution_id: nil).each do |professor|
initial_start_date = Enrollment.joins(:thesis_defense_committee_participations).
where(thesis_defense_committee_participations: { professor: professor }).minimum(:thesis_defense_date)

start_date = professor.updated_at
end_date = nil
institution_id = professor.institution_id
Expand Down Expand Up @@ -37,9 +40,14 @@ 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 diminui a data de start da affiliation em um mês
# 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?
affiliation.update(start_date: affiliation.start_date - 1.month)
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
Expand Down

0 comments on commit a84b22d

Please sign in to comment.