rhgrant10 / berserk

Python client for the lichess API
https://berserk.readthedocs.io
Other
142 stars 36 forks source link

Parameter of export_by_player since, end not working like documentation #18

Open mendezr opened 4 years ago

mendezr commented 4 years ago

Description

Follow the docs on the part of exporting games by player but is seems that since and end parameters is not working properly. I expected a subset of games filter by timestamp, instead got the max of recent games .

What I Did

start = berserk.utils.to_millis(datetime(2018, 12, 8))
end = berserk.utils.to_millis(datetime(2018, 12, 9))
games = list(client.games.export_by_player('LeelaChess', as_pgn=False, since=start, until=end,max=300))
print(len(games))

Output:
300

If I check the dates of the list I got:

print(games[0]['createdAt'], games[-1]['createdAt']) 

Output:
2020-04-14 02:57:30.645000+00:00 2020-04-01 04:02:40.694000+00:00

Reading the docs the function berserk.utils.to_millis look since and until as an int value, start and end are float. So I convert start and until to int

games = list(client.games.export_by_player('LeelaChess', as_pgn=False, since=int(start), until=int(end),max=300))
print(len(games))

Output:
291

And checking the dates

print(games[0]['createdAt'], games[-1]['createdAt']) 

Output:
2018-12-09 03:43:47.412000+00:00 2018-12-08 08:00:12.072000+00:00

It's work now. I can try to fix it make a PR if you can guide me (this my first issue)