Skip to content

Commit

Permalink
Improved queryset filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingersGat committed Nov 5, 2024
1 parent c63cec4 commit 6178bb8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions order_history/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def generate_build_order_history(self):
completion_date__lte=self.end_date
)

# Exclude builds which have no completed stock
builds = builds.exclude(completed=0)

# Construct a dict of order quantities for each part type
parts = {}
history_items = {}
Expand Down Expand Up @@ -145,6 +148,9 @@ def generate_purchase_order_history(self):
# Exclude any lines which do not map to an internal part
lines = lines.exclude(part__part=None)

# Exclude lines which have no received stock
lines = lines.exclude(received=0)

# Construct a dictionary of purchase history data to part ID
history_items = {}
parts = {}
Expand Down Expand Up @@ -199,6 +205,9 @@ def generate_sales_order_history(self):
order__shipment_date__lte=self.end_date
)

# Exclude lines which have no shipped stock
lines = lines.exclude(shipped=0)

# Construct a dictionary of sales history data to part ID
history_items = {}
parts = {}
Expand Down

0 comments on commit 6178bb8

Please sign in to comment.