[tasks] Add optional user context labels to get title
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
TODOIST_TITLE_LABELS = [
|
||||
DEFAULT_TASK_CONTEXT_LABELS = [
|
||||
"bug",
|
||||
"feature",
|
||||
"errand",
|
||||
|
||||
@ -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":
|
||||
|
||||
Reference in New Issue
Block a user