Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
extreme4all committed Jul 31, 2024
1 parent ebb949a commit c0be912
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/api/v2/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from fastapi import APIRouter, Depends, status
from fastapi.exceptions import HTTPException
from sqlalchemy.ext.asyncio import AsyncSession

from src.app.repositories.player import Player
from src.app.repositories.report import Report
Expand All @@ -19,10 +20,10 @@
@router.post("/report", status_code=status.HTTP_201_CREATED, response_model=Ok)
async def post_reports(
detections: list[Detection],
session=Depends(get_session),
session: AsyncSession = Depends(get_session),
):
global player_cache

session: AsyncSession
report_repo = Report()
player_repo = Player(session=session, cache=player_cache)

Expand All @@ -35,6 +36,7 @@ async def post_reports(
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()

_data = []
for d in data:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async def test_valid_report_unkown_reporter(custom_client):
endpoint = "/v2/report"
_data = example_data.copy()
_data["ts"] = int(time.time())
_data["reported"] = "new reporter"
_data["reporter"] = "new reporter"

# Example of a valid detection data
detection_data = [_data]
Expand Down

0 comments on commit c0be912

Please sign in to comment.