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 datetime import datetime, timedelta
from peewee import fn, JOIN 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]: 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) List of tasks ordered by last activity (updated_at)
""" """
query = ( query = (
Task.select(Task, Category.name.alias("category_name")) Task.select(Task, Category).join(Category, JOIN.LEFT_OUTER).where(~Task.deleted)
.join(Category, JOIN.LEFT_OUTER)
.where(~Task.deleted)
) )
if category: if category:
@ -117,7 +115,7 @@ def get_recently_active(num: int = 5, category: str | None = None) -> list[dict]
"text": task.text, "text": task.text,
"status": task.status, "status": task.status,
"type": task.type, "type": task.type,
"category": task.category_name, "category": task.category.name if task.category else None,
"due": task.due, "due": task.due,
"updated_at": task.updated_at, "updated_at": task.updated_at,
} }
@ -172,7 +170,7 @@ def get_due_soon(
"text": task.text, "text": task.text,
"status": task.status, "status": task.status,
"type": task.type, "type": task.type,
"category": task.category_name, "category": task.category.name if task.category else None,
"due": task.due, "due": task.due,
"days_until_due": (task.due - now).days if task.due else None, "days_until_due": (task.due - now).days if task.due else None,
} }

View File

@ -1,7 +1,7 @@
import json import json
from datetime import datetime from datetime import datetime
from peewee import fn 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 from peewee import Case, Value

View File

@ -27,16 +27,18 @@ class TableColumnConfig:
display_name: str, display_name: str,
*, *,
default=None, default=None,
enum=None,
enable_editor=False, enable_editor=False,
enum=None,
filterable=True,
preprocessor=None, preprocessor=None,
): ):
self.field = field self.field = field
self.display_name = display_name self.display_name = display_name
self.default = default self.default = default
self.enum = enum
self.preprocessor = preprocessor or (lambda x: x)
self.enable_editor = enable_editor self.enable_editor = enable_editor
self.enum = enum
self.filterable = filterable
self.preprocessor = preprocessor or (lambda x: x)
class TableEditor(App): class TableEditor(App):
@ -285,7 +287,7 @@ class TableEditor(App):
def action_start_filter(self): def action_start_filter(self):
cconf = self._active_column_config() cconf = self._active_column_config()
if cconf.filterable: if not cconf.filterable:
return return
cur_filter_val = self.filters.get(cconf.field) or "" cur_filter_val = self.filters.get(cconf.field) or ""
self._show_input("filter", cur_filter_val) self._show_input("filter", cur_filter_val)