Skip to content

Commit

Permalink
Update to new select api
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehgrantsgov committed Jan 2, 2025
1 parent 898ad5b commit 3b63968
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions api/src/services/users/get_saved_opportunities.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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())

0 comments on commit 3b63968

Please sign in to comment.