Explorar o código

[tasks] Add optional user context labels to get title

Colin Powell hai 1 mes
pai
achega
63361964ca
Modificáronse 2 ficheiros con 6 adicións e 4 borrados
  1. 1 1
      vrobbler/apps/tasks/constants.py
  2. 5 3
      vrobbler/apps/tasks/utils.py

+ 1 - 1
vrobbler/apps/tasks/constants.py

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

+ 5 - 3
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":