[qa] Share the streamed listing code between assets, shots and edits - #1192
Merged
Conversation
…ources The with-tasks routes of assets and shots carried the same twenty lines twice: the same five line comment, the same header, the same generate() closure yielding NDJSON. The vendor scoping was a third copy, in edits too, recognisable by the one line of each file that runs past 79 characters. Three helpers, one per duplication. flask_utils.rows_response answers a listing as one object or as a stream, and reads no row, so it stays in utils. permissions_service.scope_criterions_to_vendor loads the caller and their departments, so it is a service. tests/base gets the compact decoder the two test files were both carrying. EditsResource.get keeps its own partial copy on purpose: get_edits does not know vendor_departments, and passing it would filter Entity on a column that does not exist. The two edit listings therefore still disagree on whether a vendor is held to their departments. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Problem
the header, the
generate()closure yielding NDJSON, and the comment abovethem. The vendor scoping was a third copy, in edits too.
rebuild_from_compactwas duplicated in the two test files.Solution
flask_utils.rows_response, scope throughpermissions_service.scope_criterions_to_vendor, and move the compact decoderto
tests/base.EditsResource.getkeeps its own partial copy:get_editsdoes not knowvendor_departments, so the two edit listings still disagree on whether avendor is held to their departments.