23 lines
732 B
Python
23 lines
732 B
Python
import logging
|
|
|
|
from django.conf import settings
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
def get_title_from_labels(labels: list[str], user_context_labels: list[str] = []) -> str:
|
|
title = "Unknown"
|
|
task_context_labels: list = user_context_labels or settings.DEFAULT_TASK_CONTEXT_TAG_LIST
|
|
for label in labels:
|
|
# TODO We may also want to take a user list of labels instead
|
|
label = label.capitalize()
|
|
if label in task_context_labels:
|
|
title = label
|
|
continue
|
|
|
|
if title == "Unknown":
|
|
logger.warning(
|
|
"Missing a configured title context for task",
|
|
extra={"labels": labels, "task_context_labels": task_context_labels},
|
|
)
|
|
return title
|