Repository navigation
Tweaks for new index page - #984
Conversation
simply make use of the existing "ordering" query as part of DRF
|
|
||
| if latest_parts is not None: | ||
| # Get the last 5 created parts | ||
| queryset = queryset.order_by('-creation_date')[:5] |
There was a problem hiding this comment.
@eeintech the django DRF framework already provides queryset ordering functionality, you just need to add 'creation_date' to the fields available for ordering
There was a problem hiding this comment.
@SchrodingersGat Ha right, this looks much more elegant. Thanks for the improvements!
- Allow filtering by bom either valid or invalid - Use "bom_valid" as the filter (positive tense)
| # TODO: This is super expensive, database query wise... | ||
| # TODO: Need to figure out a cheaper way of making this filter query | ||
|
|
||
| if stock_to_build is not None: |
There was a problem hiding this comment.
@eeintech this approach is pretty "expensive" in terms of database hits. It runs into the N+1 query problem as the query cannot be performed in a single run.
This will need some further investigation to determine if it can be sped up
There was a problem hiding this comment.
@SchrodingersGat Right, I wasn't in love with this implementation, I'll have to think about this more...
There was a problem hiding this comment.
I just realized django-debug-toolbar can be enabled in the config, I'll check it out!
There was a problem hiding this comment.
Yeah it is a good way to see how many SQL queries are actually being executed (among other things too)
Follows on from the work done in #982