[tasks] Make tasks use user profile string
This commit is contained in:
@ -56,7 +56,7 @@ class UserProfile(TimeStampedModel):
|
||||
return pytz.timezone(self.timezone)
|
||||
|
||||
@cached_property
|
||||
def task_context_tags(self) -> list:
|
||||
def task_context_tags(self) -> list[str]:
|
||||
tag_list = [
|
||||
t.strip().capitalize()
|
||||
for t in self.task_context_tags_str.split(",")
|
||||
|
||||
@ -34,10 +34,6 @@ from videos.models import Video
|
||||
from tasks.utils import get_title_from_labels
|
||||
from webpages.models import WebPage
|
||||
|
||||
from vrobbler.apps.tasks.constants import (
|
||||
TODOIST_TITLE_LABELS
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -413,9 +409,9 @@ def todoist_scrobble_task(
|
||||
user_id: int,
|
||||
started: bool = False,
|
||||
stopped: bool = False,
|
||||
context_list: list = [],
|
||||
) -> Scrobble:
|
||||
|
||||
title = get_title_from_labels(todoist_task.get("todoist_label_list", []))
|
||||
title = get_title_from_labels(todoist_task.get("todoist_label_list", []), context_list)
|
||||
task = Task.find_or_create(title)
|
||||
|
||||
timestamp = pendulum.parse(todoist_task.get("updated_at", timezone.now()))
|
||||
@ -537,13 +533,10 @@ def emacs_scrobble_task(
|
||||
user_id: int,
|
||||
started: bool = False,
|
||||
stopped: bool = False,
|
||||
context_list: list[str] = [],
|
||||
) -> Scrobble | None:
|
||||
|
||||
prefix = ""
|
||||
suffix = ""
|
||||
|
||||
source_id = task_data.get("source_id")
|
||||
title = get_title_from_labels(task_data.get("labels", []))
|
||||
title = get_title_from_labels(task_data.get("labels", []), context_list)
|
||||
|
||||
task = Task.find_or_create(title)
|
||||
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
DEFAULT_TASK_CONTEXT_LABELS = [
|
||||
"bug",
|
||||
"feature",
|
||||
"errand",
|
||||
"chore",
|
||||
"admin",
|
||||
"computer",
|
||||
"farm",
|
||||
"baking",
|
||||
"meeting",
|
||||
"habit",
|
||||
"research",
|
||||
"exercise",
|
||||
"lifeevent",
|
||||
]
|
||||
@ -90,16 +90,12 @@ def todoist_webhook(request):
|
||||
)
|
||||
return Response({}, status=status.HTTP_304_NOT_MODIFIED)
|
||||
|
||||
user_id = (
|
||||
UserProfile.objects.filter(todoist_user_id=post_data.get("user_id"))
|
||||
.first()
|
||||
.user_id
|
||||
)
|
||||
user_profile = UserProfile.objects.filter(todoist_user_id=post_data.get("user_id")).first()
|
||||
|
||||
scrobble = None
|
||||
if todoist_task:
|
||||
scrobble = todoist_scrobble_task(
|
||||
todoist_task, user_id, stopped=task_stopped
|
||||
todoist_task, user_profile.user_id, stopped=task_stopped, context_list=user_profile.task_context_tags
|
||||
)
|
||||
|
||||
if todoist_note:
|
||||
|
||||
Reference in New Issue
Block a user