Skip to content

Commit

Permalink
⚡️ optimized the query
Browse files Browse the repository at this point in the history
  • Loading branch information
agn-7 committed Nov 29, 2023
1 parent ece7dca commit 0b60f10
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ifsguid/crud.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from typing import List
from uuid import UUID

from sqlalchemy.orm import Session
from sqlalchemy.orm import Session, joinedload

from . import models, schemas, utils


def get_interactions(
db: Session, page: int = None, per_page: int = 10
) -> List[models.Interaction]:
query = db.query(models.Interaction)
query = db.query(models.Interaction).options(
joinedload(models.Interaction.messages)
)

if page is not None:
query = query.offset((page - 1) * per_page).limit(per_page)
Expand Down

0 comments on commit 0b60f10

Please sign in to comment.