Skip to content

Commit

Permalink
refactor: move uses from dict func to method to make it easier to upd…
Browse files Browse the repository at this point in the history
…ate pydantic
  • Loading branch information
brownben committed Aug 10, 2023
1 parent 258c332 commit f1823e4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion backend/src/routes/competitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async def get_overview_for_competitor(
if not competitor:
raise HTTP_404(f"Couldn't find competitor with the id `{id}`")

return CompetitorOverview(**dict(competitor), results=results, league=league)
return CompetitorOverview(**competitor.dict(), results=results, league=league)


@router.post("/merge", response_model=Message)
Expand Down
2 changes: 1 addition & 1 deletion backend/src/routes/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async def get_results_for_event(
raise HTTP_404(f"Couldn't find event with the id `{id}`")

return EventWithResults(
**dict(event),
**event.dict(),
results=assign_position_based_on_time(results or []),
league=league,
)
7 changes: 5 additions & 2 deletions backend/src/routes/leagues.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
def competitor_to_league_result(
competitor: Competitor, number_of_events: int = 0
) -> LeagueResult:
league_result = LeagueResult(**competitor.dict())
league_result = LeagueResult.parse_obj(competitor)
league_result.points = [None] * number_of_events
return league_result

Expand Down Expand Up @@ -83,7 +83,10 @@ async def get_league(name: str) -> LeagueOverviewAuthenticated:
raise HTTP_404(f"Couldn't find league with name `{name}`")

return LeagueOverviewAuthenticated(
**result.dict(), classes=classes, events=events, groups=groups
**result.dict(),
classes=classes,
events=events,
groups=groups,
)


Expand Down
3 changes: 2 additions & 1 deletion backend/src/routes/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ async def process_upload_file(
else:
result.competitor = await Competitors.create(
NewCompetitor(
**dict(full_result), competitor_pool=event.competitor_pool
**dict(full_result),
competitor_pool=event.competitor_pool,
)
)

Expand Down

1 comment on commit f1823e4

@vercel
Copy link

@vercel vercel bot commented on f1823e4 Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

munro – ./

munro-brownben.vercel.app
munro-git-main-brownben.vercel.app
munroleagues.com
munro.vercel.app

Please sign in to comment.