Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Berserk since and until should be integers #42

Open
supermitch opened this issue Nov 17, 2021 · 1 comment
Open

Berserk since and until should be integers #42

supermitch opened this issue Nov 17, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@supermitch
Copy link

supermitch commented Nov 17, 2021

  • 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
@supermitch
Copy link
Author

I see this is a duplicate of #18

@rhgrant10 rhgrant10 added the bug Something isn't working label Apr 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants