Skip to content

Add rating and games-played fields for every account perf#1

Merged
aryanhasgithub merged 1 commit into
aryanhasgithub:mainfrom
rlrghb:add-all-perf-stats
May 24, 2026
Merged

Add rating and games-played fields for every account perf#1
aryanhasgithub merged 1 commit into
aryanhasgithub:mainfrom
rlrghb:add-all-perf-stats

Conversation

@rlrghb
Copy link
Copy Markdown
Contributor

@rlrghb rlrghb commented May 23, 2026

Summary

LichessStatistics today exposes only six rating fields and five games fields, even though /api/account returns a richer perfs object covering nine more time controls / variants and an additional correspondence_games count. This PR fills in the gap so consumers can read every perf the API publishes.

Changes

  • LichessStatistics gains rating and games fields for:
    • ultra_bullet
    • correspondence_games (rating already existed; games was missing)
    • chess960, crazyhouse, antichess, atomic, horde, king_of_the_hill, racing_kings, three_check
    • puzzle_games (already existed; kept for clarity)
  • AioLichess.get_statistics() populates all new fields from the same /api/account response — no extra HTTP calls.
  • Perfs the user has never played continue to be reported as None (not 0), preserving the existing distinction between "no record" and "zero games".
  • Snake-case Python field names map to the API's camelCase keys.

Backwards compatibility

All existing fields keep their names, types, and semantics. The change is purely additive, so this is a non-breaking minor bump (1.2.0 → 1.3.0).

Tests

Added tests/test_client.py covering:

  • A fully populated /api/account response: every new field is read correctly, and storm/racer/streak entries (which lack rating/games) are ignored.
  • A sparse response with only bullet set: every other perf comes back as None.

Motivation

Used by the Home Assistant Lichess integration, which currently can only surface 4 of the ~15 perfs Lichess users care about. A companion PR against home-assistant/core consumes the new fields.

Extend LichessStatistics to cover ultraBullet, correspondence_games, and
all eight variant perfs (chess960, crazyhouse, antichess, atomic, horde,
kingOfTheHill, racingKings, threeCheck) returned by /api/account. Perfs
the user has never played are reported as None.

Add unit tests for both the populated and sparse perf cases, and document
the new fields in the README.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@aryanhasgithub aryanhasgithub merged commit 02046a6 into aryanhasgithub:main May 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants