Skip to content

Tweaks for new index page - #984

Merged
SchrodingersGat merged 8 commits into
inventree:masterfrom
SchrodingersGat:index_page_fixes
Sep 19, 2020
Merged

SchrodingersGat merged 8 commits into
inventree:masterfrom
SchrodingersGat:index_page_fixes

Conversation

@SchrodingersGat

Copy link
Copy Markdown
Member

Follows on from the work done in #982

simply make use of the existing "ordering" query as part of DRF
Comment thread InvenTree/part/api.py

if latest_parts is not None:
# Get the last 5 created parts
queryset = queryset.order_by('-creation_date')[:5]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eeintech the django DRF framework already provides queryset ordering functionality, you just need to add 'creation_date' to the fields available for ordering

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SchrodingersGat Ha right, this looks much more elegant. Thanks for the improvements!

Comment thread InvenTree/part/api.py
# 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:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SchrodingersGat Right, I wasn't in love with this implementation, I'll have to think about this more...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized django-debug-toolbar can be enabled in the config, I'll check it out!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it is a good way to see how many SQL queries are actually being executed (among other things too)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants