LichessStatTgWeb/LichessWebServices
vrubelroman 028fd4d3e8 fix never-sent notifications for periods >= 3h, lower shared-token gap to 3s, handle both Lichess 429s
- periodic: stale-backlog suppression compared the window length with an absolute 2h,
  so every pair with period 180/360/720/1440 min was suppressed on every check
  (prod: 20 pairs of 16 users, 62 suppressions in 10 days). Now stale means the window
  exceeds the configured period by more than 2h (PeriodicMonitor._is_stale_backlog).
- SharedTokenGate min_gap 6s -> 3s. Measured with a separate test account: the JSON
  "Please only run N request(s) at a time" 429 is a concurrency limit (2 streams per
  IP / per token, slot freed at stream end) that a sequential client cannot trip, so
  the old 6s "cooldown" rationale was wrong; the HTML "Too many requests" 429 is an
  edge burst limiter (~0.45-0.9 req/s sustained) that 2-3s spacing avoids.
- lichess_client: on 429 log the body prefix (so the two limiters are distinguishable)
  and pause the gate 60s for the burst limiter only; re-raise exactly as before.
- /lastYear_or_1000games uses interactive priority (was waiting behind the backlog)
- /test_admin_notify only works from the admin chat
- stats service honours LOG_LEVEL and silences httpx INFO (bulk of its 808 MB log)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-20 21:55:30 +00:00
..
API_DOCUMENTATION.md Создание единого проекта Lichess Statistics Ecosystem 2025-10-26 20:23:26 +03:00
Dockerfile Создание единого проекта Lichess Statistics Ecosystem 2025-10-26 20:23:26 +03:00
lichess_client.py fix never-sent notifications for periods >= 3h, lower shared-token gap to 3s, handle both Lichess 429s 2026-10-20 21:55:30 +00:00
main.py fix never-sent notifications for periods >= 3h, lower shared-token gap to 3s, handle both Lichess 429s 2026-10-20 21:55:30 +00:00
models.py stop infinite retry loop on rejected Lichess tokens 2026-07-05 07:37:14 +00:00
rate_limiter.py fix never-sent notifications for periods >= 3h, lower shared-token gap to 3s, handle both Lichess 429s 2026-10-20 21:55:30 +00:00
README.md Создание единого проекта Lichess Statistics Ecosystem 2025-10-26 20:23:26 +03:00
requirements.txt Создание единого проекта Lichess Statistics Ecosystem 2025-10-26 20:23:26 +03:00
stats_service.py prioritize interactive requests over background checks in shared Lichess-token queue 2026-07-26 10:25:34 +00:00

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 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