Iai Orders Sync Tool
Periodically fetch & update information about orders from Ido Sell Shop and store it in auxiliary SQLite DB, for use for statistics.
Implemented in iai-orders-sync-tool.php. Executed by cron every ~1 hour.
TODO:
- zweryfikować *jakie* zmiany są obejmowane timestampem zmiany:
- usunięcie pozycji (np. na skutek zwrotu)
- zmiana statusu (np. wysyłka, anulowanie, reklamacja)
Fetch algorithm
- find the LATEST_SYNCED_SERIAL := MAX(orderSerialNumber)
- or certain 'pre-selected order serial' (to avoid fetching very old orders)
- fetch orders sorted by Serial Number ASC, in pages of 100, where ordersSerialNumberRange->ordersSerialNumberBegin > LATEST_SYNCED_SERIAL
- insert all fetched
- on duplicate raise exception
Keeping the mirror up-to-date
Orders can be updated in various ways in Ido Sell Shop, and we need to update local mirror to match. Concerns:
- don't miss an updated of an order
- don't perform too many API calls
- be reasonably close to up-to-date
Note, 'very important'': the "Fetch" algo above relies on the order serial numbers for keeping track of what was last updated. Do *not* insert spurious orders from the "updated" queue; only do *updates*.
Stats
- Stats: fetch, show amount of updated orders today, in last 1 day, last 3 days, last 7 days (exc. today)
Proposal:
- today: don't worry
- 1...7 days back: fetch in sets of day
- 8 ... 90 days back:
Proposal 2:
- first, fetch & update today's changed at every hour
- second, fetch & update last 7 days' cahnged at every hour