Skip to content

Commit

Permalink
Use .join() in Backend Query Logic (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaygandecha authored Dec 17, 2023
1 parent 6344d93 commit 6682c55
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions backend/services/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,10 @@ def get_events_from_organization(self, slug: str) -> list[EventDetails]:
"""

# Query the organization with the matching slug
organization = (
self._session.query(OrganizationEntity)
.filter(OrganizationEntity.slug == slug)
.one_or_none()
)

# Ensure that the organization exists
if organization is None:
return []

# Query the event with matching organization slug
events = (
self._session.query(EventEntity)
.filter(EventEntity.organization_id == organization.id)
.join(OrganizationEntity)
.where(OrganizationEntity.slug == slug)
.all()
)

Expand Down

0 comments on commit 6682c55

Please sign in to comment.