Skip to content

Commit

Permalink
fix: list_users N+1 문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
minkyu97 committed Jul 6, 2024
1 parent c15533e commit 9f4d5bb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions waffledotcom/src/apps/user/repositories.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from fastapi import Depends
from sqlalchemy.orm import Session
from sqlalchemy.orm import Session, joinedload

from waffledotcom.src.apps.user.models import User
from waffledotcom.src.database.connection import Transaction, get_db_session
Expand All @@ -15,7 +15,7 @@ def __init__(
self.transaction = transaction

def get_users(self) -> list[User]:
return self.session.query(User).all()
return self.session.query(User).options(joinedload(User.positions)).all()

def get_user_by_id(self, user_id: int) -> User | None:
return self.session.query(User).filter(User.id == user_id).first()
Expand Down

0 comments on commit 9f4d5bb

Please sign in to comment.