Skip to content

Commit

Permalink
fix max over empty sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
gardenerik committed Feb 20, 2024
1 parent 83d977f commit 2c059bc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sortiment/store/views/storefront.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ def p_func(t, q):
for p in products:
p.qty = state_d[p.id] if not p.is_unlimited else infty_string
p.totqty = all_state_d[p.id] if not p.is_unlimited else infty_string
p.timestamp = max(purchases_d.get(p.name, [(datetime_min, 0)]))[0]
purchases = purchases_d.get(p.name)
if not purchases:
purchases = [(datetime_min, 0)]
p.timestamp = max(purchases)[0]
p.priority = sum(p_func(t, q) for t, q, _ in purchases_d[p.name])
p.user_priority = sum(
p_func(t, q) for t, q, u in purchases_d[p.name] if u == user
Expand Down

0 comments on commit 2c059bc

Please sign in to comment.