bug fixed 1000 games
This commit is contained in:
parent
3226d4c162
commit
3e61fa33c4
4 changed files with 29 additions and 22 deletions
|
|
@ -190,6 +190,7 @@ class GamesOfPeriodResponse(BaseModel):
|
|||
period_start: int = Field(..., description="Начало периода (Unix timestamp)", example=1640995200)
|
||||
period_end: int = Field(..., description="Конец периода (Unix timestamp)", example=1641081600)
|
||||
games_count: int = Field(..., description="Общее количество игр", example=25)
|
||||
earliest_game_ts: Optional[int] = Field(None, description="Время самой старой найденной партии (Unix timestamp, секунды)", example=1638316800)
|
||||
data: Optional[GamesOfPeriodStats] = Field(None, description="Данные статистики игр")
|
||||
|
||||
# =============================================================================
|
||||
|
|
|
|||
|
|
@ -606,6 +606,15 @@ class StatsService:
|
|||
|
||||
# Обрабатываем игры
|
||||
games_stats = self._process_games_of_period(games, username)
|
||||
# Определяем время самой старой партии (в секундах)
|
||||
earliest_game_ts = None
|
||||
try:
|
||||
if games:
|
||||
earliest_game_ts = min(g.get('createdAt', 0) for g in games if isinstance(g.get('createdAt', None), int))
|
||||
if earliest_game_ts:
|
||||
earliest_game_ts = earliest_game_ts // 1000
|
||||
except Exception:
|
||||
earliest_game_ts = None
|
||||
|
||||
return GamesOfPeriodResponse(
|
||||
message="Статистика игр за период",
|
||||
|
|
@ -613,6 +622,7 @@ class StatsService:
|
|||
period_start=since_timestamp,
|
||||
period_end=until_timestamp,
|
||||
games_count=len(games),
|
||||
earliest_game_ts=earliest_game_ts,
|
||||
data=games_stats
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue