@@ -261,20 +261,20 @@ def __set_task_complete(username: str, tier: str, task_id: int, complete: bool):
261261 # '%s.$.taskCurrent' % tier: False}})
262262 task_coll = mydb ['taskLists' ]
263263 cleaned_tier = tier .replace ("Tasks" , "" )
264- # task_coll.update_one({'username': username}, {"$push" : {f"tiers.{cleaned_tier}.completedTasks": {}}})
265- result = task_coll .update_one (
266- {"username" : username },
267- {
268- "$push" : {
269- f"tiers.{ cleaned_tier } .completedTasks" : {"taskId" : task_id }
270- },
271- "$unset" : {
272- f"tiers.{ cleaned_tier } .currentTask" : ""
273- }
274- }
275- )
264+ if complete :
265+ print (f"tiers.{ cleaned_tier } .completedTasks" , task_id )
266+ result = task_coll .update_one (
267+ {"username" : username },
268+ {
269+ "$push" : {
270+ f"tiers.{ cleaned_tier } .completedTasks" : {"taskId" : task_id }
271+ },
272+ "$unset" : {
273+ f"tiers.{ cleaned_tier } .currentTask" : ""
274+ }
275+ }
276+ )
276277 if not complete :
277- print ('removing from completed list' )
278278 remove_completed = task_coll .update_one (
279279 {
280280 "username" : username
@@ -525,30 +525,74 @@ def get_task_progress(username: str):
525525
526526
527527def get_task_lists (username ):
528- coll = mydb ['taskAccounts' ]
529- task_query_easy = coll .find ({'username' : username }, {'easyTasks' : 1 })
530- task_query_medium = coll .find ({'username' : username }, {'mediumTasks' : 1 })
531- task_query_hard = coll .find ({'username' : username }, {'hardTasks' : 1 })
532- task_query_elite = coll .find ({'username' : username }, {'eliteTasks' : 1 })
533- task_query_master = coll .find ({'username' : username }, {'masterTasks' : 1 })
534- task_query_bosspet = coll .find ({'username' : username }, {'bossPetTasks' : 1 })
535- task_query_skillpet = coll .find ({'username' : username }, {'skillPetTasks' : 1 })
536- task_query_otherpet = coll .find ({'username' : username }, {'otherPetTasks' : 1 })
537- task_query_extra = coll .find ({'username' : username }, {'extraTasks' : 1 })
538- task_query_passive = coll .find ({'username' : username }, {'passiveTasks' : 1 })
539-
540- easy_list = task_query_easy [0 ]['easyTasks' ]
541- medium_list = task_query_medium [0 ]['mediumTasks' ]
542- hard_list = task_query_hard [0 ]['hardTasks' ]
543- elite_list = task_query_elite [0 ]['eliteTasks' ]
544- master_list = task_query_master [0 ]['masterTasks' ]
545- bosspet_list = task_query_bosspet [0 ]['bossPetTasks' ]
546- skillpet_list = task_query_skillpet [0 ]['skillPetTasks' ]
547- otherpet_list = task_query_otherpet [0 ]['otherPetTasks' ]
548- extra_list = task_query_extra [0 ]['extraTasks' ]
549- passive_list = task_query_passive [0 ]['passiveTasks' ]
550-
551- return easy_list , medium_list , hard_list , elite_list , master_list , bosspet_list , skillpet_list , otherpet_list , extra_list , passive_list
528+ coll = mydb ['taskLists' ]
529+ task_list_query = coll .find_one ({"username" : username }, {"_id" : 0 , "username" : 1 , "tiers" : 1 })
530+ bossPets = []
531+ skillPets = []
532+ otherPets = []
533+ completed_bossPet_ids = task_list_query ['tiers' ]['bossPets' ]['completedTasks' ]
534+ completed_skillPet_ids = task_list_query ['tiers' ]['skillPets' ]['completedTasks' ]
535+ completed_otherPet_ids = task_list_query ['tiers' ]['otherPets' ]['completedTasks' ]
536+
537+
538+
539+ for boss_pet_task in tasklists .boss_pet :
540+ if completed_bossPet_ids :
541+ for id in completed_bossPet_ids :
542+ if boss_pet_task .id == id ['taskId' ]:
543+ print (boss_pet_task )
544+ boss_pet_task .isCompleted = True
545+
546+ bossPets .append (boss_pet_task )
547+
548+ for skill_pet_task in tasklists .skill_pet :
549+ if completed_skillPet_ids :
550+ for id in completed_skillPet_ids :
551+ if skill_pet_task .id == id ['taskId' ]:
552+ skill_pet_task .isCompleted = True
553+
554+
555+ skillPets .append (skill_pet_task )
556+
557+ for other_pet_task in tasklists .other_pet :
558+ if completed_otherPet_ids :
559+ for id in completed_otherPet_ids :
560+ if other_pet_task .id == id ['taskId' ]:
561+ other_pet_task .isCompleted = True
562+ else :
563+ other_pet_task .isCompleted = False
564+
565+ otherPets .append (other_pet_task )
566+
567+ return bossPets , tasklists .skill_pet , tasklists .other_pet
568+ bossPets = list ()
569+ for task in tasklists .boss_pet :
570+ task_data = TaskData ()
571+ # bossPets = list(map(lambda x: x['taskId'], task_list_query['tiers']['bossPets']['completedTasks']))
572+ print (bossPets )
573+ # task_query_easy = coll.find({'username': username}, {'easyTasks': 1})
574+ # task_query_medium = coll.find({'username': username}, {'mediumTasks': 1})
575+ # task_query_hard = coll.find({'username': username}, {'hardTasks': 1})
576+ # task_query_elite = coll.find({'username': username}, {'eliteTasks': 1})
577+ # task_query_master = coll.find({'username': username}, {'masterTasks' : 1})
578+ # task_query_bosspet = coll.find({'username': username}, {'bossPetTasks': 1})
579+ # task_query_skillpet = coll.find({'username': username}, {'skillPetTasks': 1})
580+ # task_query_otherpet = coll.find({'username': username}, {'otherPetTasks': 1})
581+ # task_query_extra = coll.find({'username': username}, {'extraTasks': 1})
582+ # task_query_passive = coll.find({'username': username}, {'passiveTasks': 1})
583+
584+ # easy_list = task_query_easy[0]['easyTasks']
585+ # medium_list = task_query_medium[0]['mediumTasks']
586+ # hard_list = task_query_hard[0]['hardTasks']
587+ # elite_list = task_query_elite[0]['eliteTasks']
588+ # master_list = task_query_master[0]['masterTasks']
589+ # bosspet_list = task_query_bosspet[0]['bossPetTasks']
590+ # skillpet_list = task_query_skillpet[0]['skillPetTasks']
591+ # otherpet_list = task_query_otherpet[0]['otherPetTasks']
592+ # extra_list = task_query_extra[0]['extraTasks']
593+ # passive_list = task_query_passive[0]['passiveTasks']
594+
595+ # return easy_list, medium_list, hard_list, elite_list, master_list, bosspet_list, skillpet_list, otherpet_list, extra_list, passive_list
552596
553597
554598'''
@@ -571,7 +615,7 @@ def manual_complete_tasks(username, tier, task_id):
571615 __set_task_complete (username , tier , task_id , True )
572616 exclude_list = ['bossPetTasks' , 'skillPetTasks' , 'otherPetTasks' ]
573617 if tier in exclude_list :
574- tier = tier .replace ('Tasks' , 's ' )
618+ tier = tier .replace ('Tasks' , '' )
575619 task = user_dao .task_info_for_id (tasklists .list_for_tier (tier ), task_id )
576620 return task .name , task .asset_image , task .tip , task .wiki_link
577621
@@ -596,8 +640,9 @@ def manual_revert_tasks(username, tier, task_id):
596640 __set_task_complete (username , tier , task_id , False )
597641 exclude_list = ['bossPetTasks' , 'skillPetTasks' , 'otherPetTasks' ]
598642 if tier in exclude_list :
599- tier = tier .replace ('Tasks' , 's ' )
643+ tier = tier .replace ('Tasks' , '' )
600644 task = user_dao .task_info_for_id (tasklists .list_for_tier (tier ), task_id )
645+ task .isCompleted = False
601646 return task .name , task .asset_image , task .tip , task .wiki_link
602647
603648
@@ -1286,13 +1331,29 @@ def test():
12861331 if not isinstance (otherPets , dict ):
12871332 valid = False
12881333
1289- # if not valid:
1290- # task_coll.update_one({"username" : result['username']}, {"$set":})
1334+ if not valid :
1335+ print ("Invalid data type for user: " , result ['username' ])
1336+ task_coll .update_one (
1337+ {"username" : result ['username' ]},
1338+ {"$set" : {
1339+ "tiers.easy" : {"completedTasks" : []},
1340+ "tiers.medium" : {"completedTasks" : []},
1341+ "tiers.hard" : {"completedTasks" : []},
1342+ "tiers.elite" : {"completedTasks" : []},
1343+ "tiers.master" : {"completedTasks" : []},
1344+ "tiers.passive" : {"completedTasks" : []},
1345+ "tiers.extra" : {"completedTasks" : []},
1346+ "tiers.bossPets" : {"completedTasks" : []},
1347+ "tiers.skillPets" : {"completedTasks" : []},
1348+ "tiers.otherPets" : {"completedTasks" : []}
1349+ }
1350+ })
12911351
12921352def fix_gerni ():
12931353 task_coll = mydb ["taskLists" ]
12941354 task_coll .update_one ({"username" : "GerniFix" })
12951355 results = task_coll .find ({}, {'tiers' : 1 , 'username' : 1 })
12961356if __name__ == "__main__" :
1297- test ()
1357+ # test()
1358+ get_task_lists ('GerniSleep' )
12981359 pass
0 commit comments