api.services.review_queue ========================= .. py:module:: api.services.review_queue .. autoapi-nested-parse:: The commercial team's review queue: Models to verify for the site. A Model is to review while its ``Vérification pour site`` is unchecked and it has stock (Units ``A vendre`` or ``Non traité``) or a Variation created by operations and still ``À valider``. Units on sale come first (those meant for the site before the others): they are sold on the strength of a sheet nobody checked. Verifying sets the Model's checkbox and its Variations' ``Statut verification`` (``Vérifié``); a Variation still ``À valider`` becomes ``Validé``. Reading the queue takes ~15 s of Airtable calls (the stock is paged): it is cached and rebuilt in the background, and a verified Model leaves it at once. Attributes ---------- .. autoapisummary:: api.services.review_queue.MODEL_TABLE api.services.review_queue.VARIATION_TABLE api.services.review_queue.VERIFIED_FIELD api.services.review_queue.TO_SELL_FIELD api.services.review_queue.VARIATION_VERIFICATION_FIELD api.services.review_queue.UNIT_MODEL_LOOKUP api.services.review_queue.QUEUE_TTL_SECONDS api.services.review_queue.MODEL_CHUNK api.services.review_queue.MODEL_WORKERS api.services.review_queue.MODEL_FIELDS api.services.review_queue.Fetch api.services.review_queue.logger Functions --------- .. autoapisummary:: api.services.review_queue.build_queue api.services.review_queue.get_queue api.services.review_queue.forget api.services.review_queue.clear_cache api.services.review_queue.expire_cache api.services.review_queue.verify api.services.review_queue.unverify Module Contents --------------- .. py:data:: MODEL_TABLE :value: 'Model' .. py:data:: VARIATION_TABLE :value: 'Variation' .. py:data:: VERIFIED_FIELD :value: 'Vérification pour site' .. py:data:: TO_SELL_FIELD :value: 'to_sell_on_shopify' .. py:data:: VARIATION_VERIFICATION_FIELD :value: 'Statut verification' .. py:data:: UNIT_MODEL_LOOKUP :value: 'Model (à partir de Référence variant)' .. py:data:: QUEUE_TTL_SECONDS :value: 300 .. py:data:: MODEL_CHUNK :value: 50 .. py:data:: MODEL_WORKERS :value: 4 .. py:data:: MODEL_FIELDS .. py:data:: Fetch .. py:data:: logger .. py:function:: build_queue(options: dict[str, Any], fetch: Fetch | None = None) -> list[dict[str, Any]] Models to review, most urgent first. ``options`` is catalog_lookup.load_options() (brand and type names). .. py:function:: get_queue(options_loader: collections.abc.Callable[[], dict[str, Any]], refresh: bool = False) -> tuple[list[dict[str, Any]], float] The queue and its age in seconds. Built on the first call (or on ``refresh``); afterwards served from cache and rebuilt in the background once older than QUEUE_TTL_SECONDS (reading it takes ~15 s). .. py:function:: forget(model_id: str) -> None A Model verified (or not any more): the cached queue drops it now; an un-verified one comes back with the next rebuild. .. py:function:: clear_cache() -> None .. py:function:: expire_cache() -> None Rebuild in the background at the next read (keeps serving meanwhile). .. py:function:: verify(at: api.services.catalog_sync.AirtableGateway, model_id: str) -> dict[str, Any] Mark the Model verified for the site. Refused (409 ``shopify_decision_required``) until ``to_sell_on_shopify`` is set. .. py:function:: unverify(at: api.services.catalog_sync.AirtableGateway, model_id: str) -> dict[str, Any] Back to review: the Model unchecked, its Variations ``Non vérifié`` (a Variation validated stays ``Validé``).