Skip to content

Commit

Permalink
minor bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
extreme4all committed Jul 31, 2024
1 parent c0be912 commit f05922c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/api/v2/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ async def post_reports(
data = await report_repo.parse_data(detections)
if not data:
raise HTTPException(status.HTTP_400_BAD_REQUEST, detail="invalid data")
logger.debug(f"Working: {len(data)}")
logger.debug(f"Received: {len(data)}, Reporter: {data[0].reporter}")

# get unique list of names
player_names = list(set([d.reported for d in data] + [d.reporter for d in data]))
players = [await player_repo.get_or_insert(player_name=p) for p in player_names]
players = {p.name: p.id for p in players}
await session.commit()
players = {p.name: p.id for p in players if p}
# await session.commit()

_data = []
for d in data:
Expand Down
2 changes: 1 addition & 1 deletion src/app/repositories/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ async def insert(self, player: PlayerCreate) -> PlayerInDB:
player.name = self.sanitize_name(player.name)
sql = sqla.insert(dbPlayer).values(player.model_dump()).prefix_with("IGNORE")
await self.session.execute(sql)
# await self.session.commit()
await self.session.commit()
return await self.get(player_name=player.name)

async def get_or_insert(self, player_name: str, cached=True) -> PlayerInDB:
Expand Down

0 comments on commit f05922c

Please sign in to comment.