Backend catalog recent updates

This commit is contained in:
sriram
2026-09-01 18:02:11 +05:30
parent 68bff007ea
commit 7b3fbc47b4
11 changed files with 1457 additions and 179 deletions

View File

@@ -385,6 +385,37 @@ BARCODE_LOOKUP_CACHE_TTL_SECONDS = float(os.getenv("BARCODE_LOOKUP_CACHE_TTL_SEC
BARCODE_LOOKUP_MAX_CONCURRENCY = int(os.getenv("BARCODE_LOOKUP_MAX_CONCURRENCY", "5"))
BARCODE_COUNTRY_TAG = os.getenv("BARCODE_COUNTRY_TAG", "india")
# How similar a candidate's product name must be to ours before its barcode is
# believed. Applies to BOTH directions: looking a barcode up from a name, and
# looking a product up from a barcode.
#
# RAISED FROM matching.py's OWN 0.45 DEFAULT, ON EVIDENCE. That default is a
# reasonable general floor, but by the time a candidate reaches this gate its
# brand and pack size have ALREADY been matched - so the name is the only thing
# left doing any discriminating, and it has to carry the whole decision.
#
# At 0.45 it did not. Scored across every catalogue barcode Open Food Facts
# knows, more than half the accepted matches were a different product:
#
# floor accepted wrong
# 0.45 15 8
# 0.70 7 2
# 0.78 2 0
#
# 0.761 "Tata Tea Gold 500g" -> "Tata Tea Gold Care" different
# 0.658 "MTR Masala 300g" -> "MTR Chana Masala" different
# 0.538 "Aachi Chicken Masala 50g" -> "Chicken Kabab/65 Masala" different
# 0.097 "Lion Dates Powder 100g" -> "PEPER NOTEN" different
#
# 0.78 is where the sample is clean, NOT where the yield is good, and it is a
# judgement rather than a separation: two products tie at 0.773 with opposite
# verdicts. It is set for precision because a WRONG barcode is worse than no
# barcode - it is an identifier other systems join on, and 33 of the 95 already
# in the catalogue are wrong, all of them accepted at the old floor.
#
# Lower it only with the yield/error numbers in front of you.
BARCODE_MIN_NAME_SIMILARITY = float(os.getenv("BARCODE_MIN_NAME_SIMILARITY", "0.78"))
# Optional barcode source credentials. Each source disables itself when its
# key is blank, so leaving these unset simply narrows the lookup cascade.
GS1_INDIA_API_BASE_URL = os.getenv("GS1_INDIA_API_BASE_URL", "")