Health score updates in backend

This commit is contained in:
sriram
2026-09-04 12:06:40 +05:30
parent 1300d4c678
commit 0c3e23fac4
33 changed files with 59703 additions and 94 deletions

View File

@@ -349,6 +349,36 @@ USE_PLAYWRIGHT_FALLBACK = _bool("USE_PLAYWRIGHT_FALLBACK", "true")
# out 1x1 tracking pixels / broken placeholder images)
MIN_IMAGE_BYTES = int(os.getenv("MIN_IMAGE_BYTES", "3000"))
# ---------------------------------------------------------------------------
# USDA FoodData Central - nutrition for loose, unbranded commodities
# ---------------------------------------------------------------------------
# Open Food Facts catalogues packaged products and has no entry for a raw
# apple, which is why every fresh-produce row had no nutrition at all. USDA's
# Foundation Foods and SR Legacy datasets are laboratory analyses of raw
# commodities, published per 100 g of edible portion.
#
# NO KEY IS REQUIRED for normal operation: `nutrition_usda_service` reads a
# snapshot built from USDA's open bulk download, so an enrichment run makes zero
# outbound USDA calls. A key is only needed to look up an id the snapshot lacks,
# or to rebuild the snapshot from the live API.
#
# Plain os.getenv rather than `_require(..., feature_flag=...)` on purpose: a
# fresh checkout with no key must still import, or the whole test suite fails at
# collection time.
USE_USDA_FDC = _bool("USE_USDA_FDC", "true")
USDA_FDC_API_KEY = os.getenv("USDA_FDC_API_KEY", "").strip()
# Score newly uploaded products automatically, instead of waiting for somebody
# to remember to POST /api/admin/nutrition-intelligence/enrich. Runs as a
# background job AFTER the ingestion batch finishes, never inside it - see the
# comment at the submission site in `app/core/batch_ingest.py`.
#
# The off switch exists because this is the one part of ingestion that makes
# outbound calls per product: an operator loading a very large catalogue on a
# metered connection, or re-running an import they intend to score later in one
# controlled pass, needs a way to say "not now" without a code change.
AUTO_ENRICH_ON_UPLOAD = _bool("AUTO_ENRICH_ON_UPLOAD", "true")
# ---------------------------------------------------------------------------
# Store-catalog enrichment pipeline (app/core/store_catalog_pipeline.py)
# ---------------------------------------------------------------------------