From 50d1b6ad85a47abc7d701fd7a1af693ff0f5c463 Mon Sep 17 00:00:00 2001 From: Kris Jordan Date: Mon, 12 Aug 2024 10:37:25 -0400 Subject: [PATCH] Minor improvements to PhD Hiring Export (#577) --- backend/api/academics/hiring.py | 2 ++ backend/models/academics/hiring/phd_application.py | 4 ++-- backend/services/academics/hiring.py | 14 ++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/backend/api/academics/hiring.py b/backend/api/academics/hiring.py index 4442b191f..db4f384e2 100644 --- a/backend/api/academics/hiring.py +++ b/backend/api/academics/hiring.py @@ -242,6 +242,7 @@ def get_hiring_summary_csv( "id", "last_name", "first_name", + "pid", "onyen", "email", "program_pursued", @@ -258,6 +259,7 @@ def get_hiring_summary_csv( "id": d.id, "last_name": d.applicant.last_name, "first_name": d.applicant.first_name, + "pid": d.applicant.pid, "onyen": d.applicant.onyen, "email": d.applicant.email, "program_pursued": d.program_pursued, diff --git a/backend/models/academics/hiring/phd_application.py b/backend/models/academics/hiring/phd_application.py index effc7003b..fd9ed85a6 100644 --- a/backend/models/academics/hiring/phd_application.py +++ b/backend/models/academics/hiring/phd_application.py @@ -1,11 +1,11 @@ from pydantic import BaseModel -from ...public_user import PublicUser +from ...user import User from ..section import CatalogSectionIdentity class PhDApplicationReview(BaseModel): id: int - applicant: PublicUser + applicant: User applicant_name: str advisor: str | None program_pursued: str diff --git a/backend/services/academics/hiring.py b/backend/services/academics/hiring.py index 718a1b8e8..f2dd152cc 100644 --- a/backend/services/academics/hiring.py +++ b/backend/services/academics/hiring.py @@ -203,7 +203,7 @@ def get_phd_applicants( for application in all: phd_application = PhDApplicationReview( id=application.id, - applicant=application.user.to_public_model(), + applicant=application.user.to_model(), applicant_name=application.user.full_name(), advisor=application.advisor, program_pursued=application.program_pursued, @@ -226,10 +226,12 @@ def get_phd_applicants( .where(section_application_table.c.application_id.in_(application_ids)) .order_by(section_application_table.c.preference) ) - for section_application in self._session.execute(section_application_query): - preference, section_id, application_id = section_application + for idx, section_application in enumerate( + self._session.execute(section_application_query) + ): + _, section_id, application_id = section_application phd_applications[application_id].student_preferences.append( - f"{preference}. {sections[section_id].course_id}.{sections[section_id].number}" + f"{idx}. {sections[section_id].course_id}.{sections[section_id].number}" ) # Grab instructor preferences of applications @@ -244,9 +246,9 @@ def get_phd_applicants( ) ) instructor_preferences = self._session.scalars(instructor_review_query).all() - for review in instructor_preferences: + for idx, review in enumerate(instructor_preferences): phd_applications[review.application_id].instructor_preferences.append( - f"{review.preference}. {review.course_site.sections[0].course_id}.{review.course_site.sections[0].number}" + f"{idx}. {review.course_site.sections[0].course_id}.{review.course_site.sections[0].number}" ) return list(phd_applications.values())