|
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 38s
Errors from Lichess (timeouts/5xx/invalid tokens) were being disguised as "no activity" (HTTP 200, games_count/puzzles_in_period=0), causing the bot to silently advance its checkpoint past real, undetected activity. Puzzle-fetch failures weren't counted as errors at all, and the periodic task died permanently after 5 consecutive errors with no way to recover short of a manual restart. /setperiod also unconditionally reset the checkpoint, dropping the window between the last check and the command. - API now returns success=false/502 on real errors instead of masking them as zero activity (models.py, stats_service.py, main.py) - Puzzle-fetch errors are now treated the same as game-fetch errors: retry the same window instead of reporting "no puzzles" - Notification delivery failures no longer silently advance the checkpoint - Replaced the hard 5-error kill switch with capped backoff that keeps retrying indefinitely, plus an admin-bot notification if a player's monitoring has been failing for a prolonged period (~2h+) - /setperiod only clears the checkpoint when disabling notifications, preserving continuity when a period is just changed Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| API_DOCUMENTATION.md | ||
| Dockerfile | ||
| lichess_client.py | ||
| main.py | ||
| models.py | ||
| rate_limiter.py | ||
| README.md | ||
| requirements.txt | ||
| stats_service.py | ||
Lichess Statistics API
REST API сервис для получения статистики игроков Lichess.org по играм и решению задач.
Возможности
- Получение статистики за сегодняшний день
- Получение статистики за вчерашний день
- Получение статистики за последние 7 дней
- Поддержка режимов игры: Bullet, Blitz, Rapid
- Статистика по решению задач (пазлов)
- Расчет изменения рейтинга
- Подсчет побед, поражений и ничьих
Запуск с Docker
1. Сборка и запуск контейнера
# Сборка образа
docker-compose build
# Запуск сервиса
docker-compose up -d
2. Проверка работы
Сервис будет доступен по адресу: http://localhost:8000
- Документация API: http://localhost:8000/docs
- Проверка здоровья: http://localhost:8000/health
API Endpoints
Получить статистику за сегодня
GET /stats/{username}/today
Получить статистику за вчера
GET /stats/{username}/yesterday
Получить статистику за неделю
GET /stats/{username}/week
Примеры использования
Статистика за сегодня
curl http://localhost:8000/stats/vrubelroman/today
Статистика за вчера
curl http://localhost:8000/stats/vrubelroman/yesterday
Статистика за неделю
curl http://localhost:8000/stats/vrubelroman/week
Формат ответа
{
"message": "Статистика за сегодняшний день",
"data": {
"username": "vrubelroman",
"tasks": {
"total": 28,
"solved": 25,
"unsolved": 3
},
"games": {
"bullet": {
"games_played": 7,
"rating_change": 30,
"final_rating": 2320,
"wins": 5,
"losses": 0,
"draws": 0
},
"blitz": {
"games_played": 5,
"rating_change": 32,
"final_rating": 2224,
"wins": 5,
"losses": 0,
"draws": 0
},
"rapid": {
"games_played": 2,
"rating_change": -10,
"final_rating": 2210,
"wins": 1,
"losses": 1,
"draws": 0
}
}
}
}
Остановка сервиса
docker-compose down
Логи
Для просмотра логов:
docker-compose logs -f