api.services.auctions_sync¶
Copies the auction price tracker’s followed lots into the auctions Airtable base, every minute.
The tracker’s GET /export gives the lots ever followed that changed since the last run (all of them on the first run), their price history and their auctions. Each table is upserted by its tracker id (“ID enchère”, “ID modèle”, “ID lot”, “ID”), so a repeated or interrupted run creates no duplicate; Redis remembers what was last sent per row (only changed rows are written), the Airtable record ids (for the links) and the photos already copied. Photos are downloaded here and uploaded as files: the base keeps its own copies, even after the auction site removes them. Nothing is ever deleted from the base.
Attributes¶
Classes¶
Functions¶
|
|
|
|
|
Module Contents¶
- api.services.auctions_sync.logger¶
- api.services.auctions_sync.PROVIDERS¶
- api.services.auctions_sync.PHOTO_BUDGET = 150¶
- api.services.auctions_sync.MAX_PHOTO_BYTES = 5242880¶
- api.services.auctions_sync.PHOTO_RETRY_FIRST = 600¶
- api.services.auctions_sync.PHOTO_RETRY_MAX = 21600¶
- api.services.auctions_sync.OVERLAP¶
- api.services.auctions_sync.KEY = 'auctions:airtable'¶
- api.services.auctions_sync.USER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64) RewakeAPI auctions sync'¶
- class api.services.auctions_sync.Sync(base: pyairtable.Base, tracker_url: str, tracker_token: str, redis: redis.Redis)¶
- base¶
- tracker_url¶
- tracker_headers¶
- redis¶
- upsert_changed(table: str, rows: dict[str, dict[str, Any]], merge_on: str) dict[str, str]¶
Writes the rows (tracker id -> fields) that changed since they were last sent; returns every row’s Airtable record id.
- copy_photos(lots: list[dict[str, Any]], lot_ids: dict[str, str]) tuple[int, int]¶
Uploads the photos not copied yet, PHOTO_BUDGET at most; returns (copied, still to copy).
- run() dict[str, Any]¶
- retry_photos() int¶
Queues again the photos of every lot whose Airtable record has none (e.g. refused by the site before refusals were retried); the next runs copy them. Returns the lots queued.
- resend() None¶
The next run reads every followed lot again and writes those whose fields differ (e.g. after a new field), keeping the photos already copied, unlike reset().
- reset() None¶
Forgets what was sent: the next run sends everything again (upserts, so no duplicate).
- api.services.auctions_sync.auction_fields(a: dict[str, Any]) dict[str, Any]¶
- api.services.auctions_sync.lot_fields(lot: dict[str, Any], auctions: dict[str, str], models: dict[str, str]) dict[str, Any]¶
- api.services.auctions_sync.history_fields(h: dict[str, Any], lots: dict[str, str]) dict[str, Any]¶