Commit 4fa4489d7d011d52b20bbe15856493f1dc388de6

Authored by mykhaly
1 parent 1d65400d

Remake `get_complaint_index_by_complaintID`

@@ -430,10 +430,14 @@ def get_object_index_by_id(data, object_id): @@ -430,10 +430,14 @@ def get_object_index_by_id(data, object_id):
430 430
431 431
432 def get_complaint_index_by_complaintID(data, complaintID): 432 def get_complaint_index_by_complaintID(data, complaintID):
  433 + if not data:
  434 + return 0
433 for index, element in enumerate(data): 435 for index, element in enumerate(data):
434 if element['complaintID'] == complaintID: 436 if element['complaintID'] == complaintID:
435 - return index  
436 - raise IndexError 437 + break
  438 + else:
  439 + index += 1
  440 + return index
437 441
438 442
439 def get_document_index_by_id(data, document_id): 443 def get_document_index_by_id(data, document_id):
Please register or login to post a comment