Skip to content

Berserk since and until should be integers #42

@supermitch

Description

@supermitch
  • berserk version: berserk-downstream 0.11.6
  • Python version: Python 3.9.5
  • Operating System: Mac

Description

Games export API expects integer timestamps, but berserk sends floats.

If you go here: https://lichess.org/api#operation/apiGamesUser
You see that since and until expect integers.

utils.to_millis(dt) does not return integer seconds, it returns floats, per https://docs.python.org/3/library/datetime.html#datetime.datetime.timestamp

As is, the berserk timestamps are completely ignored.

What I Did

Try running the example from the docs, but I changed to a 10 minute window:

start = berserk.utils.to_millis(dt.datetime(2018, 12, 8, 1, 10))
end = berserk.utils.to_millis(dt.datetime(2018, 12, 8, 1, 20))
print(f'Query from {start} to {end}')
games = lichess.games.export_by_player('LeelaChess', since=start, until=end, max=300)
print(f'Found {len(list(games))} Leela games')

start, end = int(start), int(end)  # Convert to ints
print(f'Query from {start} to {end}')
games = lichess.games.export_by_player('LeelaChess', since=start, until=end, max=300)
print(f'Found {len(list(games))} Leela games')

Output:

Query from 1544260200000.0 to 1544260800000.0
Found 300 Leela games  # Hit max!
Query from 1544260200000 to 1544260800000
Found 3 Leela games  # Presumably correct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions