Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions templates/collection_log_import.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ <h3 class="center">Import Results For: <p class="incomplete">{{rs_username}}</p>
<div class="rank-results-row center">
<p class="complete">Elite Tasks: <p class="incomplete">{{elite}}</p></p>
</div>
<p>Reminder: Dairy Tasks are not tracked via TempleOSRS you will need to manually complete.</p>
<h5 class="center">Browse a task list to see what tasks you've completed already!</h3>
</div>

Expand Down
27 changes: 18 additions & 9 deletions templesync.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def import_logs(player_name: str, site_tasks: list):


def check_logs(username: str, site_tasks: list, action: str):
def find_by_id(items, target_id):
return [item for item in items if item['id'] == target_id]
def format_completed_tasks(completed_tasks: set):
# iterate over the completed tasks and create a list of dictionaries
formatted_tasks = []
Expand All @@ -49,26 +51,33 @@ def format_completed_tasks(completed_tasks: set):
})
return formatted_tasks

player_data = temple_player_data(username)
cleaned_player_data = temple_player_data(username)
missing_tasks = list()
completed_tasks = set()
for task in site_tasks:
task_data = task.get('colLogData', None)
if task_data:
log_count = 0
for item in task_data['include']:
for log_slot in player_data['data']['items']:
if item['id'] == log_slot['id']:
log_count += 1
print(f"Checking item: {item['name']} with ID: {item['id']}")
find_item = find_by_id(cleaned_player_data, item['id'])
if find_item:
log_count += 1
print(f"Found item: {find_item[0]['name']} with ID: {find_item[0]['id']}")
print(f"Log count: {log_count}, Required: {task_data['logCount']}")
if log_count == task_data['logCount']:
completed_tasks.add(int(task['_id']))
print(f"Completed task: {task['name']} with ID: {task['_id']}")
break
if log_count != task_data['logCount']:
missing_tasks.append(task['name'])


if log_count != task_data['logCount']:
missing_tasks.append(task['name'])
print(f"Missing task: {task['name']} with ID: {task['_id']}")
if action == 'check':
print("Missing tasks:")
for task in missing_tasks:
print(task)
return missing_tasks
else:

print(completed_tasks)
return format_completed_tasks(completed_tasks)