GothenburgBitFactory / GothenburgBitFactory/tasklib
TaskQuerySet should be sortable by urgency IMO
- Dominant language
- Python
- Stars
- 159
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
TaskQuerySet returns an iterable object. It would make sense for me if this object is sorted by urgency or at least sortable by urgency. For this to work there should be `__lt__` defined for Task. The wished behaviour can also be accomplished by similar code by extending those classes:
```python
#!/usr/bin/env python3
from tasklib import TaskWarrior
from tasklib.task import Task
from tasklib.task import TaskQuerySet
tw = TaskWarrior(data_location='~/.task')
nexttasks = tw.tasks.pending()
class TaskSortable(Task):
def __init__(self, task):
super().__init__(task.backend)
self._data = task._data
def __lt__(self,other):
return self['urgency'] > other['urgency']
class TaskQuerySetSortable(TaskQuerySet):
def __init__(self, taskqueryset):
super().__init__(taskqueryset.backend, taskqueryset.filter_obj)
def _execute(self):
tasks = []
for task in super()._execute():
tasks.append(TaskSortable(task))
return tasks
if not nexttasks:
print('No current tasks')
else:
for task in sorted(TaskQuerySetSortable(nexttasks)):
print("%s %s %s, " % (task['id'],task['description'],task['urgency']))
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.