Skip to content

Commit

Permalink
Merge pull request #6668 from hotosm/fastapi-refactor
Browse files Browse the repository at this point in the history
User statistics refactored.
  • Loading branch information
prabinoid authored Dec 30, 2024
2 parents e2a11d9 + 33d10db commit ebfd533
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 178 deletions.
2 changes: 1 addition & 1 deletion backend/api/users/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async def get(
description: Internal Server Error
"""
stats_dto = await UserService.get_detailed_stats(username, db)
return stats_dto.model_dump(by_alias=True)
return stats_dto


@router.get("/{user_id}/statistics/interests/")
Expand Down
7 changes: 3 additions & 4 deletions backend/models/dtos/user_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,12 @@ class UserCountryContributed(BaseModel):
class UserCountriesContributed(BaseModel):
"""DTO for countries a user has contributed"""

def __init__(self):
super().__init__()
self.countries_contributed = []

countries_contributed: List[UserCountryContributed] = Field([], alias="countries")
total: int = Field(None)

class Config:
populate_by_name = True


class UserContributionDTO(BaseModel):
date: datetime
Expand Down
Loading

0 comments on commit ebfd533

Please sign in to comment.