Skip to content

Commit

Permalink
fix: use images.openfoodfacts.org to fetch OCR files
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Oct 7, 2024
1 parent 65e16dd commit 59fa01f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions robotoff/off.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,8 @@ def generate_json_ocr_url(product_id: ProductIdentifier, image_id: str) -> str:
:param image_id: the image ID (ex: `1`, `2`,...)
:return: the generated image URL
"""
return (
settings.BaseURLProvider.static(product_id.server_type)
+ f"/images/products{generate_json_ocr_path(product_id, image_id)}"
return settings.BaseURLProvider.image_url(
product_id.server_type, generate_json_ocr_path(product_id, image_id)
)


Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_random_question(client, mocker):
"insight_id": insight_id,
"insight_type": "category",
"server_type": "off",
"source_image_url": "https://images.openfoodfacts.net/images/products/1/ingredients_fr.51.400.jpg",
"source_image_url": "https://images.openfoodfacts.net/images/products/000/000/000/0001/ingredients_fr.51.400.jpg",
}
],
"status": "found",
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/insights/test_question.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def test_category_question_formatter(
"insight_id": str(insight.id),
"insight_type": InsightType.category.name,
"server_type": ServerType.off.name,
"source_image_url": "https://images.openfoodfacts.net/images/products/111/111/111/1/front_fr.10.400.jpg",
"source_image_url": "https://images.openfoodfacts.net/images/products/000/111/111/1111/front_fr.10.400.jpg",
}


Expand Down Expand Up @@ -221,7 +221,7 @@ def test_label_question_formatter(
"insight_id": str(insight.id),
"insight_type": InsightType.label.name,
"server_type": ServerType.off.name,
"source_image_url": "https://images.openfoodfacts.net/images/products/111/111/111/1/1.400.jpg",
"source_image_url": "https://images.openfoodfacts.net/images/products/000/111/111/1111/1.400.jpg",
}

if ref_image_url is not None:
Expand Down

0 comments on commit 59fa01f

Please sign in to comment.