Feat/painreportlist endpoint - #315
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add a new batch knowledge panel endpoint supporting one or multiple barcodes in a single request.
The new route:
accepts comma-separated barcodes and returns a response indexed by barcode, with:
panelsfor successful resultserrorsfor per-barcode failuresThe existing single-product endpoint:
is preserved for backward compatibility.
The implementation follows the API format discussed in the October GitHub mobile/Dart discussion:
/knowledge-panel/routecodequery parameterlanghandling is unchanged and still managed through the existing middleware.countryquery parameters are currently ignored server-side (FastAPI ignores undeclared params), so there is no impact on the suffering calculation logic at the moment.Code changes
Added batch endpoint:
Added parallel processing using
asyncioAdded batch response format:
{ "panels": { "123": {...} }, "errors": { "456": {...} } }Preserved existing single-barcode endpoint
Added unit tests covering:
Refactored OFF HTTP calls to reuse a shared
httpx.AsyncClientinstead of creating a new client per request
Added retry handling for transient OFF API failures (
429, network issues, etc.)How to test
You can test either through the OFF app or directly with
curl.Existing endpoint regression test
curl "http://127.0.0.1:8000/off/v1/knowledge-panel/3017620422003?lang=fr"New batch endpoint with a single barcode
curl "http://127.0.0.1:8000/off/v1/knowledge-panel/?code=3017620422003&lang=fr"New batch endpoint with multiple barcodes
curl "http://127.0.0.1:8000/off/v1/knowledge-panel/?code=3017620422003,3228857000166&lang=fr"Batch endpoint with mixed success/failure cases
curl "http://127.0.0.1:8000/off/v1/knowledge-panel/?code=3017620422003,3450970045360&lang=fr"