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 v.varValue > 0:
if 'Item_' in v.name: if 'Item_' in v.name:
item_id = v.name.replace('Item_', '') 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 # add item to list and then remove from master item list
if item: form_items.append(item) if item: form_items.append(item)
elif 'Bundle_' in v.name: elif 'Bundle_' in v.name:
bundle_id = v.name.replace('Bundle_', '') bundle_id = v.name.replace('Bundle_', '')
bundle = solver_run.get_bundle(bundle_id) bundle = solver_run.get_bundle(int(bundle_id))
if bundle: if bundle:
for item in bundle.items: for item in bundle.items:

View File

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