diff --git a/src/tt/controller/summaries.py b/src/tt/controller/summaries.py index 22ddf4a..9e0b021 100644 --- a/src/tt/controller/summaries.py +++ b/src/tt/controller/summaries.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta from peewee import fn, JOIN -from .db import Task, Category, TaskStatus +from ..db import Task, Category, TaskStatus def get_category_summary(num: int = 5) -> list[dict]: @@ -101,9 +101,7 @@ def get_recently_active(num: int = 5, category: str | None = None) -> list[dict] List of tasks ordered by last activity (updated_at) """ query = ( - Task.select(Task, Category.name.alias("category_name")) - .join(Category, JOIN.LEFT_OUTER) - .where(~Task.deleted) + Task.select(Task, Category).join(Category, JOIN.LEFT_OUTER).where(~Task.deleted) ) if category: @@ -117,7 +115,7 @@ def get_recently_active(num: int = 5, category: str | None = None) -> list[dict] "text": task.text, "status": task.status, "type": task.type, - "category": task.category_name, + "category": task.category.name if task.category else None, "due": task.due, "updated_at": task.updated_at, } @@ -172,7 +170,7 @@ def get_due_soon( "text": task.text, "status": task.status, "type": task.type, - "category": task.category_name, + "category": task.category.name if task.category else None, "due": task.due, "days_until_due": (task.due - now).days if task.due else None, } diff --git a/src/tt/controller/tasks.py b/src/tt/controller/tasks.py index 3834a3e..50525fa 100644 --- a/src/tt/controller/tasks.py +++ b/src/tt/controller/tasks.py @@ -1,7 +1,7 @@ import json from datetime import datetime from peewee import fn -from .db import db, Task, Category, TaskStatus, SavedSearch +from ..db import db, Task, Category, TaskStatus, SavedSearch from peewee import Case, Value diff --git a/src/tt/tui/editor.py b/src/tt/tui/editor.py index 8a4fa4f..4454ed0 100644 --- a/src/tt/tui/editor.py +++ b/src/tt/tui/editor.py @@ -27,16 +27,18 @@ class TableColumnConfig: display_name: str, *, default=None, - enum=None, enable_editor=False, + enum=None, + filterable=True, preprocessor=None, ): self.field = field self.display_name = display_name self.default = default - self.enum = enum - self.preprocessor = preprocessor or (lambda x: x) self.enable_editor = enable_editor + self.enum = enum + self.filterable = filterable + self.preprocessor = preprocessor or (lambda x: x) class TableEditor(App): @@ -285,7 +287,7 @@ class TableEditor(App): def action_start_filter(self): cconf = self._active_column_config() - if cconf.filterable: + if not cconf.filterable: return cur_filter_val = self.filters.get(cconf.field) or "" self._show_input("filter", cur_filter_val)