[tasks] Add optional user context labels to get title

This commit is contained in:
2025-06-27 10:37:09 -04:00
parent 40b54b27f4
commit 63361964ca
2 changed files with 6 additions and 4 deletions

View File

@ -1,4 +1,4 @@
TODOIST_TITLE_LABELS = [ DEFAULT_TASK_CONTEXT_LABELS = [
"bug", "bug",
"feature", "feature",
"errand", "errand",

View File

@ -1,14 +1,16 @@
import logging import logging
from tasks.constants import TODOIST_TITLE_LABELS from tasks.constants import DEFAULT_TASK_CONTEXT_LABELS
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def get_title_from_labels(labels: list[str]) -> str: def get_title_from_labels(labels: list[str], user_context_labels: list[str] = []) -> str:
title = "Unknown" title = "Unknown"
task_context_labels: list = user_context_labels or DEFAULT_TASK_CONTEXT_LABELS
for label in labels: for label in labels:
if label in TODOIST_TITLE_LABELS: # TODO We may also want to take a user list of labels instead
if label in task_context_labels:
title = label.capitalize() title = label.capitalize()
if title == "Unknown": if title == "Unknown":