Beispiel #1
0
    def update_product(self, insight: ProductInsight) -> AnnotationResult:
        store: str = insight.data['store']
        store_tag: str = insight.value_tag

        product = get_product(insight.barcode, ['stores_tags'])

        if product is None:
            return MISSING_PRODUCT_RESULT

        stores_tags: List[str] = product.get('stores_tags') or []

        if store_tag in stores_tags:
            return ALREADY_ANNOTATED_RESULT

        add_store(insight.barcode, store)
        return UPDATED_ANNOTATION_RESULT
Beispiel #2
0
    def update_product(
            self,
            insight: ProductInsight,
            auth: Optional[OFFAuthentication] = None) -> AnnotationResult:
        product = get_product(insight.barcode, ["stores_tags"])

        if product is None:
            return MISSING_PRODUCT_RESULT

        stores_tags: List[str] = product.get("stores_tags") or []

        if insight.value_tag in stores_tags:
            return ALREADY_ANNOTATED_RESULT

        add_store(
            insight.barcode,
            insight.value,
            insight_id=insight.id,
            server_domain=insight.server_domain,
            auth=auth,
        )
        return UPDATED_ANNOTATION_RESULT