Repository navigation
parts table: supplier and supplier part number columns - #1574
Merged
Merged
Conversation
The suppliers of a part and their part numbers were only visible on the part's info page, so a parts list could neither show nor be sorted by where something was bought. Both columns are hidden by default and can be enabled in the column chooser or via the default columns setting (supplier, supplier_part_number). They are sorted in the filter query by the first supplier name / part number of the part, using the same aggregated join as the storage location column. Parts without a supplier (or with only empty part numbers) are kept at the end in both directions, as the DBMS disagree on where NULLs are sorted. The suppliers are fetch-joined in the detail query, so rendering the columns does not trigger a query per supplier.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1574 +/- ##
=========================================
Coverage 64.46% 64.47%
- Complexity 10210 10217 +7
=========================================
Files 762 762
Lines 32711 32752 +41
=========================================
+ Hits 21087 21116 +29
- Misses 11624 11636 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
The parts table could show the stock at a supplier, but not which suppliers a part has or their order numbers, and it could not be sorted by either.
This adds two columns, both hidden by default so the stock table is unchanged:
Both are available in the column chooser and in the default-columns setting (
supplier,supplier_part_numberinTABLE_PARTS_DEFAULT_COLUMNS; documented in docs/configuration.md).Both sort server-side in the filter query, by
NATSORT(MIN(_suppliers.name))andNATSORT(MIN(NULLIF(_orderdetails.supplierpartnr, ''))), using the existing_orderdetails/_suppliersjoin and group-by-part, as the storage location column does. Parts without a supplier (or with only empty numbers) sort last in both directions. The detail query fetch-joinsorderdetails.supplier, so rendering does not lazy-load suppliers.Tested on sqlite with ~18k parts and ~18k order details: sorting by either column takes about the same time as sorting by name. MySQL and PostgreSQL run in CI but the new sort was not exercised there by hand.
Notes for review:
orderField(aCASE WHEN MIN(...) IS NULLfollowed by the NATSORT one), relying on the adapter appending the direction to the last expression only. Happy to move that into an explicit order-by if you prefer.