Skip to content
This repository has been archived by the owner on Dec 15, 2024. It is now read-only.

Commit

Permalink
feat: implement filters getting
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemSBulgakov committed Nov 22, 2024
1 parent 3dee7ea commit beab488
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions backend/src/modules/events/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,24 @@ async def get_all_filters_locations() -> list[LocationFilter]:
"""
Get all locations.
"""
return []
# From all 'location' fields of events, get unique values
locations: list[LocationFilter] = list()
for event in await events_repository.read_all():
for location in event.location:
if location not in locations:
locations.append(LocationFilter(country=location.country, region=location.region, city=location.city))
return list(locations)


@router.get("/search/filters/disciplines", responses={200: {"description": "All disciplines"}})
async def get_all_filters_disciplines() -> list[DisciplineFilter]:
"""
Get all disciplines.
"""
return []
# From all 'sport' and 'disciplines' fields of events, get unique values
disciplines: list[DisciplineFilter] = list()
for event in await events_repository.read_all():
for discipline in event.discipline:
if discipline not in disciplines:
disciplines.append(DisciplineFilter(sport=event.sport, discipline=discipline))
return list(disciplines)

0 comments on commit beab488

Please sign in to comment.