Skip to content

Commit

Permalink
Hotfix clutch for completed tasks since local api changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Nixellion committed Jan 16, 2023
1 parent cf84bc9 commit e429673
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
24 changes: 12 additions & 12 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,6 @@ def get_project_items(project_name):
if item['checked'] is False or config['show_completed_tasks']:
items.append(item_text)

# Cleanup completed tasks
if item['content'] == "TEST":
print
if config['remove_completed_tasks'] and item['checked'] is True:
remember_task(item['content'])
if config['clean_up_completed_tasks']:
print(f"Deleting task '{item['content']}'")
todoist_api.delete_item(item)
else:
print(f"Config tells me to skip clean_up_completed_tasks: {item['content']}")
elif not config['remove_completed_tasks']:
print(f"Config tells me to skip remove_completed_tasks: {item['content']}")
return items


Expand Down Expand Up @@ -464,6 +452,18 @@ def notifier_task_hash(task, label=""):

debug(output_text)

# Cleanup completed tasks
for item in todoist_api.get_completed_tasks():
if config['remove_completed_tasks']:
remember_task(item['content'])
if config['clean_up_completed_tasks']:
print(f"Deleting task '{item['content']}'")
todoist_api.delete_item(item)
else:
print(f"Config tells me to skip clean_up_completed_tasks: {item['content']}")
elif not config['remove_completed_tasks']:
print(f"Config tells me to skip remove_completed_tasks: {item['content']}")

# Copy if copy
if config['export_file_as']:
if os.path.exists(config['export_file_as']):
Expand Down
18 changes: 9 additions & 9 deletions todoist_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def get_items(self, items_type="items", force_update=False):
}
).json()
items = response[items_type]
if items_type == "items":
items.extend(self.get_completed_tasks()['items'])
# if items_type == "items":
# items.extend(self.get_completed_tasks())
self._state_cache[items_type] = items
else:
items = self._state_cache[items_type]
Expand Down Expand Up @@ -93,7 +93,7 @@ def delete_items(self, items):
return responses

def get_completed_tasks(self):
return self.post("https://api.todoist.com/sync/v9/completed/get_all", headers=self.headers).json()
return self.post("https://api.todoist.com/sync/v9/completed/get_all", headers=self.headers).json()['items']

def add_item(self, item_data, quick=False):
print(f"TODOIST add_item: {item_data}")
Expand Down Expand Up @@ -122,9 +122,9 @@ def add_item(self, item_data, quick=False):
return task

# def add_task(self,)
# if __name__ == "__main__":
# # Testing
# with open(os.path.join(appdir, 'config.yaml'), 'r') as f:
# config = yaml.safe_load(f.read())
# api = TodoistAPI(config['todoist_token'])
# print(api.get_completed_tasks()['items'])
if __name__ == "__main__":
# Testing
with open(os.path.join(appdir, 'config.yaml'), 'r') as f:
config = yaml.safe_load(f.read())
api = TodoistAPI(config['todoist_token'])
print(api.get_completed_tasks()['items'])

0 comments on commit e429673

Please sign in to comment.