Skip to content
Snippets Groups Projects
Unverified Commit 1aadf683 authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

temporary fix to prevent 500 on program.academic_years

parent 8453fac7
No related branches found
No related tags found
No related merge requests found
......@@ -12,27 +12,36 @@ module Education::Program::WithAlumni
alias_attribute :university_person_alumni, :alumni
has_many :alumni_experiences, -> { distinct },
class_name: 'University::Person::Experience',
through: :alumni,
source: :experiences
alias_attribute :university_person_experiences, :alumni_experiences
has_many :alumni_organizations, -> { distinct },
class_name: 'University::Organization',
through: :alumni_experiences,
source: :organization
alias_attribute :university_person_alumni_organizations, :alumni_organizations
has_many :academic_years, -> { distinct },
class_name: 'Education::AcademicYear',
through: :cohorts,
source: :academic_year
alias_attribute :education_academic_years, :academic_years
# TODO: Find a fix for wrong table name on WHERE clause
# SELECT "education_academic_years".*
# FROM "education_academic_years"
# INNER JOIN "education_cohorts"
# ON "education_academic_years"."id" = "education_cohorts"."academic_year_id"
# WHERE "cohorts"."program_id" = '<uuid>'
#
# has_many :academic_years, -> { distinct },
# class_name: 'Education::AcademicYear',
# through: :cohorts,
# source: :academic_year
# alias_attribute :education_academic_years, :academic_years
# Dénormalisation des alumni pour le faceted search
has_and_belongs_to_many :university_people,
class_name: 'University::Person',
foreign_key: 'education_program_id',
association_foreign_key: 'university_person_id'
def academic_years
Education::AcademicYear.where(id: cohorts.pluck(:academic_year_id))
end
end
end
......@@ -27,7 +27,7 @@
class University::Person::Experience < ApplicationRecord
include WithUniversity
belongs_to :person
belongs_to :organization
belongs_to :organization, class_name: "University::Organization"
scope :ordered, -> { order(from_year: :desc)}
end
......@@ -18,7 +18,7 @@ module University::Person::WithEducation
source: :target,
source_type: "Education::Program"
has_many :experiences
has_many :experiences, class_name: "University::Person::Experience"
has_and_belongs_to_many :cohorts,
class_name: '::Education::Cohort',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment