handle empty tasks return

This commit is contained in:
simon 2023-03-07 17:31:21 +07:00
parent 2850988bfe
commit 1f08ea9eea
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
1 changed files with 3 additions and 3 deletions

View File

@ -17,13 +17,13 @@ class TaskManager:
if not all_keys:
return False
all_results = [handler.get_single(i) for i in all_keys]
return sorted(all_results, key=lambda d: d["date_done"])
return [handler.get_single(i) for i in all_keys]
def get_tasks_by_name(self, task_name):
"""get all tasks by name"""
all_results = self.get_all_results()
if not all_results:
return False
return [i for i in all_results if i.get("name") == task_name]