I noticed some discrepancies in the number of returned results between Order.find and Order.count in the Shopify API. Local timezone is taken into account with Order.find but not with Order.count.
We end up with different numbers of orders even though the setup is exactly the same.
Is that expected behavior?
- `shopify_python_api` version: 8.1.0
- `pyactiveresource` version: 2.2.0
- Shopify API version used: 2020-10
If you search the forum you will see similar issues raised. From what I recall querying for orders can provide unexpected results when narrowing down to timestamps. It seems that the API service pretty much ignores the time and just assesses the date. If you try similar queries through the GraphQL API (versus the REST API) I'm wondering if this issue is consistent there. Also, perhaps try an older API version...
Thanks for the additional context @Greg_Kujawa.
I did some additional testing and it seems that the discrepancy between Order.find and Order.count only appears when the timezone is not specified.
I've created an issue on the shopify api python library repo (https://github.com/Shopify/shopify_python_api/issues/444) but it might be worth creating an issue directly assigned to the REST API. Do you know where such issues are usually tracked?
Thanks for reporting the discrepancy noted between Order.find and the Order.count. I've done some initial testing using the REST Admin, and I haven't been able to reproduce the said behaviour. Could you confirm you see the same discrepancy when you use the REST Admin? If you do, could you kindly provide the x-request-id's of the two calls made, and I'll be able to look into this more.
Hi @syf_ ,
Sorry for the late response.
I confirm I see a discrepancy on the REST Admin API as well.
In that case we have count.json gives 25 and orders.json gives 0 order even though the parameters are the same (?status=any&created_at_min=2021-01-13T23:00:00:00).
Tagging @paulomarg as well who was active on the github thread.
Thanks for providing me with the examples.
After doing some investigation, we've been able to identify what may be causing this issue. Our devs have been made aware, and they are currently looking into the issue. I'm unable to give a timeline for this, but I'd update you immediately I hear anything back.
In the meantime, a current workaround is to use UTC time and not your local time for the
/orders.json endpoint. I know this is an inconvenience and I assure you our dev team is working to fix this issue.
Let me know if the workaround I suggested works, or you have any additional questions related to this issue.
I always find it more consistent and less quirks to remember by defaulting the online shop's time zone to UTC, as well as defaulting to that for all of my own code. Especially if I have client-side code and the users could obviously be in different time zones. In terms of and JWT's for my own hosted apps, for Shopify queries, for reporting, etc.