From 3b639681d2c9a43c0b8f0f0b18899a682953c6bf Mon Sep 17 00:00:00 2001 From: Michael Huneke Date: Thu, 2 Jan 2025 10:06:21 -0500 Subject: [PATCH] Update to new select api --- api/src/services/users/get_saved_opportunities.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/api/src/services/users/get_saved_opportunities.py b/api/src/services/users/get_saved_opportunities.py index 390d82952..0b630e0af 100644 --- a/api/src/services/users/get_saved_opportunities.py +++ b/api/src/services/users/get_saved_opportunities.py @@ -1,6 +1,8 @@ import logging from uuid import UUID +from sqlalchemy import select + from src.adapters import db from src.db.models.opportunity_models import Opportunity from src.db.models.user_models import UserSavedOpportunity @@ -11,9 +13,11 @@ def get_saved_opportunities(db_session: db.Session, user_id: UUID) -> list[UserSavedOpportunity]: logger.info(f"Getting saved opportunities for user {user_id}") - return ( - db_session.query(UserSavedOpportunity) + stmt = ( + select(UserSavedOpportunity) .join(Opportunity) - .filter(UserSavedOpportunity.user_id == user_id) - .all() + .where(UserSavedOpportunity.user_id == user_id) ) + + result = db_session.execute(stmt) + return list(result.scalars().all())