-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add number_of_spares
field to catalogue items #416
#426
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #426 +/- ##
========================================
Coverage 97.92% 97.92%
========================================
Files 45 45
Lines 1592 1594 +2
========================================
+ Hits 1559 1561 +2
Misses 33 33 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, have some minor comments to make.
|
||
# Computed | ||
number_of_spares: Optional[int] = Field( | ||
default=None, description="Number of spares currently available within this catalogue item if known" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default=None, description="Number of spares currently available within this catalogue item if known" | |
default=None, description="The number of spares currently available within this catalogue item" |
All of the other descriptions start with The
and if known
doesn't seem necessary since other optional fields don't include this text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, the others I have done have not as I thought it was unnecessary to have the The
, but I will for the sake of keeping it the same in the file, the rest can be unified later. I think the if known
is worth emphasising in this case? They others are directly edited by the user, so I expect if there is an optional description
then they would understand that when its None
it just doesn't have one rather than it not being known, whereas the spares it is specifically because it isn't known not just that it doesn't have one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think it makes sense to leave if known
in for this case. I thought there were some fields similar to number_of_spares
(Optional, not known but exists), but I just realised I was looking at the Patch Schema where everything is made Optional
More of a general comment about the migration scripts, but we now have 2 separate migration scripts for catalogue items, for the |
Yes that is correct, the migrations have to be done in the right order at the right time. I had the same thought and created another PR to implement something like alembic #430 to address these. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some final comments in regards to the mock_data
**CATALOGUE_ITEM_DATA_REQUIRED_VALUES_ONLY, | ||
"catalogue_category_id": str(ObjectId()), | ||
"manufacturer_id": str(ObjectId()), | ||
"number_of_spares": None, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**CATALOGUE_ITEM_DATA_REQUIRED_VALUES_ONLY, | |
"catalogue_category_id": str(ObjectId()), | |
"manufacturer_id": str(ObjectId()), | |
"number_of_spares": None, | |
} | |
**CATALOGUE_ITEM_DATA_REQUIRED_VALUES_ONLY, | |
"catalogue_category_id": str(ObjectId()), | |
"manufacturer_id": str(ObjectId()), | |
} |
It's optional, so it shouldn't be included in the REQUIRED_VALUES_ONLY
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason it is like this is because the CatalogueItemBase
doesn't have it set to None
automatically. The idea being that with the actual calculation, I never want it to default to anything - it should only be None if the calculation itself returns it, but forgetting to set it will cause an error and prompt a developer to use the calculation to populate it instead. The others are set to None because if you forget to set it, its fine.
In the |
I have put some comments at the top of the mock_data.py to try and explain these models. All the |
Thank you for the explanation; helped clear everything up. |
Description
See #416.
Testing instructions
Agile board tracking
Closes #416