From 63361964ca56b718a4588b52a21fc192201766ef Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Fri, 27 Jun 2025 10:37:09 -0400 Subject: [PATCH] [tasks] Add optional user context labels to get title --- vrobbler/apps/tasks/constants.py | 2 +- vrobbler/apps/tasks/utils.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/vrobbler/apps/tasks/constants.py b/vrobbler/apps/tasks/constants.py index adee049..4fca01c 100644 --- a/vrobbler/apps/tasks/constants.py +++ b/vrobbler/apps/tasks/constants.py @@ -1,4 +1,4 @@ -TODOIST_TITLE_LABELS = [ +DEFAULT_TASK_CONTEXT_LABELS = [ "bug", "feature", "errand", diff --git a/vrobbler/apps/tasks/utils.py b/vrobbler/apps/tasks/utils.py index acd9d0e..5ab626b 100644 --- a/vrobbler/apps/tasks/utils.py +++ b/vrobbler/apps/tasks/utils.py @@ -1,14 +1,16 @@ import logging -from tasks.constants import TODOIST_TITLE_LABELS +from tasks.constants import DEFAULT_TASK_CONTEXT_LABELS 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" + task_context_labels: list = user_context_labels or DEFAULT_TASK_CONTEXT_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() if title == "Unknown":