Skip to content

Commit

Permalink
Fix issue loading student application preferences (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisJordan authored Jul 31, 2024
1 parent d08800c commit dab3540
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions backend/services/academics/hiring.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def _load_applicants(
}

def _load_application_preferences(
self, applications: dict[int, ApplicationEntity]
self, site: CourseSiteEntity, applications: dict[int, ApplicationEntity]
) -> dict[int, int]:
"""
Loads all application preferences for a given course site.
Expand All @@ -305,11 +305,16 @@ def _load_application_preferences(
"""
preferences_query = (
select(
ApplicationReviewEntity.application_id,
func.min(ApplicationReviewEntity.preference),
section_application_table.c.application_id,
func.min(section_application_table.c.preference),
)
.where(section_application_table.c.application_id.in_(applications.keys()))
.where(
section_application_table.c.section_id.in_(
[section.id for section in site.sections]
)
)
.where(ApplicationReviewEntity.application_id.in_(applications.keys()))
.group_by(ApplicationReviewEntity.application_id)
.group_by(section_application_table.c.application_id)
)
result = self._session.execute(preferences_query)
return {row[0]: row[1] + 1 for row in result}
Expand All @@ -333,7 +338,9 @@ def _to_review_models(
application_reviews = self._load_application_reviews(site_entity)
applications = self._load_applications(application_reviews)
applicants = self._load_applicants(applications)
applicant_preferences = self._load_application_preferences(applications)
applicant_preferences = self._load_application_preferences(
site_entity, applications
)
return [
ApplicationReviewOverview(
id=review.id,
Expand Down

0 comments on commit dab3540

Please sign in to comment.