pre-filter 100% constraint items
This commit is contained in:
@ -3,6 +3,7 @@ import io
|
||||
import re
|
||||
from tokenize import String
|
||||
|
||||
from models.item import Item
|
||||
|
||||
def items_csv_to_dict(items_csv_reader, solver_run):
|
||||
items = []
|
||||
@ -41,7 +42,15 @@ def items_csv_to_dict(items_csv_reader, solver_run):
|
||||
if row[key]:
|
||||
item[col] = row[key]
|
||||
|
||||
items.append(item)
|
||||
# confirm item is only added if it meets the criteria of 100% constraints as a pre-filter
|
||||
valid_item = True
|
||||
item = Item.parse_obj(item)
|
||||
for constraint in solver_run.constraints:
|
||||
attribute = item.get_attribute(constraint.reference_attribute)
|
||||
if attribute and constraint.minimum == 100 and int(attribute.value) == 0:
|
||||
valid_item = False
|
||||
|
||||
if valid_item: items.append(item)
|
||||
|
||||
return items
|
||||
|
||||
|
Reference in New Issue
Block a user