event search based on updated gives records outside the time bounds
Closed this issue · 2 comments
Hi,
This is with reference to the recently updated events example given in https://github.com/predicthq/sdk-py/blob/master/usecases/events/search_by_date.py
When i specify the time element in the lte
, I am not getting the correct results.
search_params = {
'country' : 'NZ',
'updated' : {
'tz' : 'UTC',
'gte' : '2022-01-27 00:00:00',
'lte' : '2022-01-27 23:00:00'}
}
for event in phq_client.events.search(**search_params):
print(event.rank, event.category, event.title, event.updated, event.timezone)
Assuming lte
stands for less-than-equal, I am expecting events that are updated only until 2022-01-27 23:00:00 UTC
but I am getting events beyond that. Appreciate if you could kindly check and let me know if I am doing something wrong ?
Output :
65 sports Perth Wildcats vs New Zealand Breakers 2022-01-27 00:57:48+00:00 Pacific/Auckland
50 sports Sky Sport Breakers v Perth Wildcats 2022-01-27 00:56:04+00:00 Pacific/Auckland
74 sports Highlanders vs Crusaders 2022-01-27 06:10:48+00:00 Pacific/Auckland
72 sports Wellington Firebirds vs Canterbury Kings 2022-01-27 22:07:11+00:00 Pacific/Auckland
========> 61 sports Canterbury Kings vs Wellington Firebirds 2022-01-27 23:16:27+00:00 Pacific/Auckland <======
61 sports Central Stags vs Canterbury Kings 2022-01-27 05:03:37+00:00 Pacific/Auckland
61 sports Central Hinds vs Canterbury Magicians 2022-01-27 02:00:24+00:00 Pacific/Auckland
Hi @amit-agni ,
Thanks for reporting this issue.
At the moment, the Python SDK only supports date ranges (and not datetime ranges) for the updated
parameter. Your lte
(it does mean less than or equal) value is converted to '2022-01-27T23:59:59'
before it is sent to our API.
We are looking at updating the SDK to support datetimes and will update this issue and our documentation once it's done.
Best regards,
Matthieu
Hi @amit-agni,
Thanks again for reporting this issue !
We just published a new version of the Python SDK:
From now on, if you provide a DateTime instead of a Date to a lt/lte
filter, it will now be taken into account.
Here are a bit more details on how we handle the lt/lte
filters values:
filter | value provided to the sdk search function | actual value sent to the api |
---|---|---|
lt | 2018-01-01 | 2018-01-01T00:00:00 |
lt | 2018-01-01T12:30:00 | 2018-01-01T12:30:00 |
lte | 2018-01-01 | 2018-01-01T23:59:59 |
lte | 2018-01-01T12:30:00 | 2018-01-01T12:30:00 |
I'm going to close this issue for now, but please upgrade to version 1.12.0
and do not hesitate to reopen this issue if you face any issues related to this update.
Best regards,
Ludovic