an id is an int

This commit is contained in:
Adrian Manteza 2022-03-22 20:29:03 +00:00
parent 9d15112320
commit ee77d888b5
2 changed files with 4 additions and 4 deletions

View File

@ -99,12 +99,12 @@ def solution_items(variables, solver_run):
if v.varValue > 0:
if 'Item_' in v.name:
item_id = v.name.replace('Item_', '')
item = solver_run.get_item(item_id)
item = solver_run.get_item(int(item_id))
# add item to list and then remove from master item list
if item: form_items.append(item)
elif 'Bundle_' in v.name:
bundle_id = v.name.replace('Bundle_', '')
bundle = solver_run.get_bundle(bundle_id)
bundle = solver_run.get_bundle(int(bundle_id))
if bundle:
for item in bundle.items:

View File

@ -26,12 +26,12 @@ class SolverRun(BaseModel):
def get_item(self, item_id: int) -> Item or None:
for item in self.items:
if str(item.id) == item_id:
if item.id == item_id:
return item
def get_bundle(self, bundle_id: int) -> Bundle or None:
for bundle in self.bundles:
if str(bundle.id) == bundle_id:
if bundle.id == bundle_id:
return bundle
def get_constraint_by_type(self, type: str) -> Constraint or None: