2626'''
2727
2828
29- def get_user (username ) -> UserDatabaseObject :
30- coll = mydb ['taskAccounts' ]
31- users = list (coll .find ({'username' : username }))
32- if len (users ) == 0 :
33- raise Exception ("No user found with username " + username )
34- old_user_data = users [0 ]
35- return convert_database_user (migrate_database_user_to_new_format (old_user_data ))
29+ # def get_user_2 (username) -> UserDatabaseObject:
30+ # coll = mydb['taskAccounts']
31+ # users = list(coll.find({'username': username}))
32+ # if len(users) == 0:
33+ # raise Exception("No user found with username " + username)
34+ # old_user_data = users[0]
35+ # return convert_database_user(migrate_database_user_to_new_format(old_user_data))
3636
3737
3838# For new taskList data format - Replaces above after migration
39- def get_user_2 (username ) -> UserDatabaseObject :
39+ def get_user (username ) -> UserDatabaseObject :
4040 coll = mydb ['taskLists' ]
4141 users = list (coll .find ({'username' : username }))
4242 if len (users ) == 0 :
@@ -45,89 +45,156 @@ def get_user_2(username) -> UserDatabaseObject:
4545 return convert_database_user (user_data )
4646
4747
48+ # '''
49+ # add_task_account:
50+
51+ # The add_task_account function create document for the user in the taskAccounts collection.
52+ # The document is a dictionary with some of the keys being lists of dictionaries.
53+ # The document is structured as follows:
54+ # {
55+ # _id : randomly generated id,
56+ # username : username,
57+ # isOfficial : True/False,
58+ # lmsEnabled : True/False,
59+ # easyTasks: [
60+ # {
61+ # _id : #,
62+ # taskname : {
63+ # name of the task : image matching the task, # would have done this differently since it horrible
64+ # LMS : True/False
65+ # },
66+ # status: Incomplete/Complete,
67+ # taskCurrent : True/False,
68+ # taskTip : tip for the task,
69+ # wikiLink : link to the wiki page for the task
70+ # }
71+ # ],
72+ # mediumTasks: [ same as easyTasks ],
73+ # hardTasks: [ same as easyTasks ],
74+ # eliteTasks: [ same as easyTasks ]
75+ # bossPetTasks: [ same as easyTasks except does not include taskTip ],
76+ # otherPetTasks: [ same as easyTasks except does not include taskTip ],
77+ # skillingPetTasks: [ same as easyTasks except does not include taskTip ],
78+ # extraTasks: [ same as easyTasks except does not include taskTip ],
79+ # passiveTasks: [ same as easyTasks except does not include taskTip ]
80+ # }
81+
82+ # Args:
83+ # str: username - username of the user.
84+ # list: completions - list of tasks
85+ # bool: isofficial - True/False
86+ # bool: lmsenabled - True/False
87+
88+ # Returns:
89+ # None
90+
91+ # '''
92+
93+
94+ # def add_task_account(username, isOfficial, lmsEnabled):
95+ # coll = mydb['taskAccounts']
96+
97+ # def combine_tasks(tasks: list[TaskData]):
98+ # new_tasks = []
99+ # for task in tasks:
100+ # new_tasks.append(
101+ # {
102+ # "_id": task.id,
103+ # "taskname": {task.name: task.asset_image, 'LMS': task.is_lms},
104+ # "status": 'Incomplete',
105+ # "taskCurrent": False,
106+ # "taskTip": task.tip,
107+ # "wikiLink": task.wiki_link,
108+ # "taskImage": task.wiki_image
109+ # }
110+ # )
111+ # return new_tasks
112+
113+ # taskAccount = {
114+ # "username": str(username),
115+ # "isOfficial": bool(isOfficial),
116+ # "lmsEnabled": bool(lmsEnabled),
117+ # "easyTasks": combine_tasks(tasklists.easy),
118+ # "mediumTasks": combine_tasks(tasklists.medium),
119+ # "hardTasks": combine_tasks(tasklists.hard),
120+ # "eliteTasks": combine_tasks(tasklists.elite),
121+ # "masterTasks": combine_tasks(tasklists.master),
122+ # "bossPetTasks": combine_tasks(tasklists.boss_pet),
123+ # "skillPetTasks": combine_tasks(tasklists.skill_pet),
124+ # "otherPetTasks": combine_tasks(tasklists.other_pet),
125+ # "extraTasks": combine_tasks(tasklists.extra),
126+ # "passiveTasks": combine_tasks(tasklists.passive)
127+ # }
128+
129+ # coll.insert_one(taskAccount)
130+
131+
132+
133+
48134'''
49135add_task_account:
50136
51- The add_task_account function create document for the user in the taskAccounts collection.
52- The document is a dictionary with some of the keys being lists of dictionaries.
137+ The add_task_account function creates the document for the user in the taskLists collection.
53138The document is structured as follows:
54139{
55- _id : randomly generated id,
56- username : username,
57- isOfficial : True/False,
58- lmsEnabled : True/False,
59- easyTasks: [
60- {
61- _id : #,
62- taskname : {
63- name of the task : image matching the task, # would have done this differently since it horrible
64- LMS : True/False
140+ _id : randomly generated id user id,
141+ username: '',
142+ isOfficial: true/false,
143+ lmsEnabled: false/false,
144+ tiers: {
145+ easyTier: {
146+ currentTask: {
147+ "taskId": Matches the ids in task JSONs,
148+ "assignedDate": "some date/time format"
65149 },
66- status: Incomplete/Complete,
67- taskCurrent : True/False,
68- taskTip : tip for the task,
69- wikiLink : link to the wiki page for the task
150+ completedTasks: [ # only stores completed tasks
151+ {
152+ "taskId": "Maybe a new id field here that matches new field in task list jsons?",
153+ "completionDate": "some date/time format", # both dates are nullable
154+ "assignedDate": "some date/time format from above assignedDate field"
155+ },...
156+ ],
70157 }
71- ],
72- mediumTasks: [ same as easyTasks ],
73- hardTasks: [ same as easyTasks ],
74- eliteTasks: [ same as easyTasks ]
75- bossPetTasks: [ same as easyTasks except does not include taskTip ],
76- otherPetTasks: [ same as easyTasks except does not include taskTip ],
77- skillingPetTasks: [ same as easyTasks except does not include taskTip ],
78- extraTasks: [ same as easyTasks except does not include taskTip ],
79- passiveTasks: [ same as easyTasks except does not include taskTip ]
158+ medium: {same as easyTier},
159+ hard: {same as easyTier},
160+ elite: {same as easyTier},
161+ master: {same as easyTier},
162+ passive: {same as easyTier},
163+ extra: {same as easyTier},
164+ bossPets: {same as easyTier},
165+ skillPets: {same as easyTier},
166+ otherPets: {same as easyTier}
167+ }
80168}
81169
82170Args:
83171 str: username - username of the user.
84- list: completions - list of tasks
85- bool: isofficial - True/False
86- bool: lmsenabled - True/False
172+ bool: is_official - True/False
173+ bool: lms_enabled - True/False
87174
88175Returns:
89176 None
90177
91178'''
92-
93-
94- def add_task_account (username , isOfficial , lmsEnabled ):
95- coll = mydb ['taskAccounts' ]
96-
97- def combine_tasks (tasks : list [TaskData ]):
98- new_tasks = []
99- for task in tasks :
100- new_tasks .append (
101- {
102- "_id" : task .id ,
103- "taskname" : {task .name : task .asset_image , 'LMS' : task .is_lms },
104- "status" : 'Incomplete' ,
105- "taskCurrent" : False ,
106- "taskTip" : task .tip ,
107- "wikiLink" : task .wiki_link ,
108- "taskImage" : task .wiki_image
109- }
110- )
111- return new_tasks
112-
113- taskAccount = {
179+ def add_task_account (username , is_official , lms_enabled ):
180+ coll = mydb ['taskLists' ]
181+ coll .insert_one ({
114182 "username" : str (username ),
115- "isOfficial" : bool (isOfficial ),
116- "lmsEnabled" : bool (lmsEnabled ),
117- "easyTasks" : combine_tasks (tasklists .easy ),
118- "mediumTasks" : combine_tasks (tasklists .medium ),
119- "hardTasks" : combine_tasks (tasklists .hard ),
120- "eliteTasks" : combine_tasks (tasklists .elite ),
121- "masterTasks" : combine_tasks (tasklists .master ),
122- "bossPetTasks" : combine_tasks (tasklists .boss_pet ),
123- "skillPetTasks" : combine_tasks (tasklists .skill_pet ),
124- "otherPetTasks" : combine_tasks (tasklists .other_pet ),
125- "extraTasks" : combine_tasks (tasklists .extra ),
126- "passiveTasks" : combine_tasks (tasklists .passive )
127- }
128-
129- coll .insert_one (taskAccount )
130-
183+ "isOfficial" : bool (is_official ),
184+ "lmsEnabled" : bool (lms_enabled ),
185+ 'tiers' : {
186+ 'easy' : [],
187+ 'medium' : [],
188+ 'hard' : [],
189+ 'elite' : [],
190+ 'master' : [],
191+ 'passive' : [],
192+ 'extra' : [],
193+ 'bossPets' : [],
194+ 'skillPets' : [],
195+ 'otherPets' : []
196+ }
197+ })
131198
132199'''
133200get_taskCurrent
@@ -1146,3 +1213,4 @@ def to_user(data):
11461213
11471214if __name__ == "__main__" :
11481215 pass
1216+
0 commit comments