@@ -524,32 +524,27 @@ def get_task_lists(username):
524524
525525
526526 for boss_pet_task in tasklists .boss_pet :
527- if completed_bossPet_ids :
528- for id in completed_bossPet_ids :
529- if boss_pet_task .id == id ['taskId' ]:
530- boss_pet_task .isCompleted = True
531-
527+ if any (x .get ("taskId" ) == boss_pet_task .id for x in completed_bossPet_ids ):
528+ boss_pet_task .isCompleted = True
529+ else :
530+ boss_pet_task .isCompleted = False
532531 bossPets .append (boss_pet_task )
533532
534533 for skill_pet_task in tasklists .skill_pet :
535- if completed_skillPet_ids :
536- for id in completed_skillPet_ids :
537- if skill_pet_task .id == id ['taskId' ]:
538- skill_pet_task .isCompleted = True
539-
540-
534+ if any (x .get ("taskId" ) == skill_pet_task .id for x in completed_skillPet_ids ):
535+ skill_pet_task .isCompleted = True
536+ else :
537+ skill_pet_task .isCompleted = False
541538 skillPets .append (skill_pet_task )
542539
543540 for other_pet_task in tasklists .other_pet :
544- if completed_otherPet_ids :
545- for id in completed_otherPet_ids :
546- if other_pet_task .id == id ['taskId' ]:
547- other_pet_task .isCompleted = True
548-
549-
541+ if any (x .get ("taskId" ) == other_pet_task .id for x in completed_otherPet_ids ):
542+ other_pet_task .isCompleted = True
543+ else :
544+ other_pet_task .isCompleted = False
550545 otherPets .append (other_pet_task )
551546
552- return bossPets , tasklists . skill_pet , tasklists . other_pet
547+ return bossPets , skillPets , otherPets
553548 # task_query_easy = coll.find({'username': username}, {'easyTasks': 1})
554549 # task_query_medium = coll.find({'username': username}, {'mediumTasks': 1})
555550 # task_query_hard = coll.find({'username': username}, {'hardTasks': 1})
0 commit comments