Store the stock a supplier has for a part, as reported by the info providers - #1538
Open
killecaptron wants to merge 2 commits into
Open
Store the stock a supplier has for a part, as reported by the info providers#1538killecaptron wants to merge 2 commits into
killecaptron wants to merge 2 commits into
Conversation
The info provider system caches the DTOs it received from a provider as serialized objects, in a cache pool which is not part of the cache directory and therefore survives an update of Part-DB. Whenever a DTO class gains a property, unserializing an object which was cached by an older version leaves that property uninitialized, so the first access to it fails with a typed property error until the cache happens to expire (up to four days later). Add a version marker to every cache key of a DTO, which has to be increased whenever the structure of the DTOs changes: old entries are then simply never read again and expire on their own. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…oviders
Most info providers tell how many parts a distributor currently has on
hand, but Part-DB threw that information away, even though it is one of
the things one wants to see when deciding where to order a part from.
Orderdetails now carry an available amount, filled by the info provider
system from Digikey, Mouser and TrustedParts. Null means the stock is
unknown, which is deliberately different from a stock of 0 ("out of
stock").
A stock is volatile and therefore only meaningful together with its age,
so the time the value was retrieved at is always stored along with it,
and shown wherever the stock is shown. For the same reason the value is
not editable by hand: it is written by the info provider system only,
and the merger keeps the newer of two values instead of the target's.
The stock is shown in the ordering information of a part, and as an
optional column in the parts table and in the project BOM.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1538 +/- ##
=========================================
Coverage 62.39% 62.40%
- Complexity 9879 9902 +23
=========================================
Files 736 736
Lines 31779 31840 +61
=========================================
+ Hits 19829 19870 +41
- Misses 11950 11970 +20 ☔ 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.
Note: this builds on #1530 and contains its commit, since a new DTO field is exactly the case that
fix is about. Once #1530 is merged this branch rebases onto it and the commit disappears.
Every info provider reports how much stock a distributor has, and Part-DB throws that away. It is
one of the first things you want to know when deciding where to order, and today it means opening
the distributor's page for each offer.
An orderdetail now stores the stock the provider reported, together with the time it was retrieved
at. Both are always written as a pair: a number without its age is misleading, because provider
stock goes stale within days, and there would be no way to tell a value from this morning from one
from three months ago. For the same reason the field is not part of the orderdetail form - it is
provider data, and setAvailableAmount() takes the value and its timestamp together.
Read from Digi-Key (the stock of the selected packaging, falling back to the product's), Mouser,
Octopart, Canopy and TrustedParts. In the merger the newer value wins, unlike the other fields:
stock is volatile, so a fresher reading replaces an older one, while null - meaning "unknown" -
never overwrites a known value.
Shown in the purchase information of a part with the time it was read at, plus a column in the part
table and one in the project BOM, both hidden by default: the BOM one answers "can I build this
project right now", which is otherwise a lot of clicking.
The migration is multi-platform (MySQL, SQLite, PostgreSQL); doctrine:schema:validate reports no
difference beyond what master already reports.