Skip to content

Commit

Permalink
[Refactor] get reported user by user's id (#45)
Browse files Browse the repository at this point in the history
## Description
- get reported user by user's id
- change Pydantic models
<!-- Add a more detailed description of the changes if needed. -->

## Related Issue

<!-- If your PR refers to a related issue, link it here. -->
  • Loading branch information
nahyun0121 authored Dec 3, 2023
2 parents cdc29bc + c94db90 commit ab0c291
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions app/crud/crud_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
def create_report(
db: Session, reporter_id: int, report_in: ReportUser
) -> ReportResponse:
# Get the reported user by user name
reported_user = (
db.query(User).filter(User.username == report_in.reported_user_name).first()
)
# Get the reported user by user's id
reported_user = db.query(User).filter(User.id == report_in.reported_id).first()

if not reported_user:
raise HTTPException(status_code=400, detail="Reported user not found")
Expand Down
6 changes: 2 additions & 4 deletions app/models/domain/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@


class ReportUser(BaseModel):
reported_user_name: str
reported_id: int
reason: str


class ReportResponse(BaseModel):
class ReportResponse(ReportUser):
reporter_id: int
reported_id: int
reason: str

class Config:
orm_mode = True

0 comments on commit ab0c291

Please sign in to comment.