some small fixes

This commit is contained in:
James Turk 2025-01-06 16:07:51 -06:00
parent c9e8571a85
commit 5a0c6abad5
3 changed files with 11 additions and 11 deletions

View File

@ -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,
}

View File

@ -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

View File

@ -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)