mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-03 13:58:47 +00:00
Fixes result limiting
- Required for index page
This commit is contained in:
parent
487794a938
commit
1239d4af16
@ -646,6 +646,20 @@ class PartList(generics.ListCreateAPIView):
|
|||||||
|
|
||||||
queryset = queryset.filter(pk__in=parts_need_stock)
|
queryset = queryset.filter(pk__in=parts_need_stock)
|
||||||
|
|
||||||
|
# Optionally limit the maximum number of returned results
|
||||||
|
# e.g. for displaying "recent part" list
|
||||||
|
max_results = params.get('max_results', None)
|
||||||
|
|
||||||
|
if max_results is not None:
|
||||||
|
try:
|
||||||
|
max_results = int(max_results)
|
||||||
|
|
||||||
|
if max_results > 0:
|
||||||
|
queryset = queryset[:max_results]
|
||||||
|
|
||||||
|
except (ValueError):
|
||||||
|
pass
|
||||||
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
filter_backends = [
|
filter_backends = [
|
||||||
|
@ -816,6 +816,18 @@ class StockList(generics.ListCreateAPIView):
|
|||||||
print("After error:", str(updated_after))
|
print("After error:", str(updated_after))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Optionally, limit the maximum number of returned results
|
||||||
|
max_results = params.get('max_results', None)
|
||||||
|
|
||||||
|
if max_results is not None:
|
||||||
|
try:
|
||||||
|
max_results = int(max_results)
|
||||||
|
|
||||||
|
if max_results > 0:
|
||||||
|
queryset = queryset[:max_results]
|
||||||
|
except (ValueError):
|
||||||
|
pass
|
||||||
|
|
||||||
# Also ensure that we pre-fecth all the related items
|
# Also ensure that we pre-fecth all the related items
|
||||||
queryset = queryset.prefetch_related(
|
queryset = queryset.prefetch_related(
|
||||||
'part',
|
'part',
|
||||||
|
@ -102,7 +102,7 @@ addHeaderAction('bom-validation', '{% trans "BOM Waiting Validation" %}', 'fa-ti
|
|||||||
loadSimplePartTable("#table-latest-parts", "{% url 'api-part-list' %}", {
|
loadSimplePartTable("#table-latest-parts", "{% url 'api-part-list' %}", {
|
||||||
params: {
|
params: {
|
||||||
ordering: "-creation_date",
|
ordering: "-creation_date",
|
||||||
limit: {% settings_value "PART_RECENT_COUNT" %},
|
max_results: {% settings_value "PART_RECENT_COUNT" %},
|
||||||
},
|
},
|
||||||
name: 'latest_parts',
|
name: 'latest_parts',
|
||||||
});
|
});
|
||||||
@ -132,7 +132,7 @@ addHeaderAction('stock-to-build', '{% trans "Required for Build Orders" %}', 'fa
|
|||||||
loadStockTable($('#table-recently-updated-stock'), {
|
loadStockTable($('#table-recently-updated-stock'), {
|
||||||
params: {
|
params: {
|
||||||
ordering: "-updated",
|
ordering: "-updated",
|
||||||
limit: {% settings_value "STOCK_RECENT_COUNT" %},
|
max_results: {% settings_value "STOCK_RECENT_COUNT" %},
|
||||||
},
|
},
|
||||||
name: 'recently-updated-stock',
|
name: 'recently-updated-stock',
|
||||||
grouping: false,
|
grouping: false,
|
||||||
|
@ -441,7 +441,6 @@ function loadPartTable(table, url, options={}) {
|
|||||||
|
|
||||||
$(table).inventreeTable({
|
$(table).inventreeTable({
|
||||||
url: url,
|
url: url,
|
||||||
sortName: 'name',
|
|
||||||
method: 'get',
|
method: 'get',
|
||||||
queryParams: filters,
|
queryParams: filters,
|
||||||
groupBy: false,
|
groupBy: false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user