Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 224c165d72 | |||
| bf7d2514f2 | |||
| 4e37bc5ab9 | |||
| 125da84f4e | |||
| 36ceb4c7fe | |||
| 88a3831975 | |||
| 63361964ca | |||
| 40b54b27f4 | |||
| a7eca4b9a7 | |||
| d152412e99 | |||
| 3ba6c6b6e4 |
13
PROJECT.org
13
PROJECT.org
@ -1,6 +1,7 @@
|
|||||||
#+title: TODOs
|
#+title: TODOs
|
||||||
|
|
||||||
* Backlog [6/23]
|
* Backlog [0/17]
|
||||||
|
** TODO [#A] Tasks from org-mode should properlly update notes and leave them out of the body :vrobbler:bug:tasks:
|
||||||
** TODO [#A] Fix small bug in views for TV series where next episode is now None :vrobbler:bug:personal:videos:
|
** TODO [#A] Fix small bug in views for TV series where next episode is now None :vrobbler:bug:personal:videos:
|
||||||
|
|
||||||
#+begin_src python
|
#+begin_src python
|
||||||
@ -47,7 +48,6 @@ Would be nice to have some loose connection to the actual event in my Garmin pro
|
|||||||
Could be as simple as a JSON form on the scrobble detail page (do I have have one of those yet?).
|
Could be as simple as a JSON form on the scrobble detail page (do I have have one of those yet?).
|
||||||
** TODO [#B] Explore a good way to show notes and descriptions from scrobbles to users :personal:project:scrobbling:vrobbler:spike:
|
** TODO [#B] Explore a good way to show notes and descriptions from scrobbles to users :personal:project:scrobbling:vrobbler:spike:
|
||||||
** TODO [#B] Add webdav syncing to retroarch imports :vrobbler:videogames:webdav:feature:project:personal:
|
** TODO [#B] Add webdav syncing to retroarch imports :vrobbler:videogames:webdav:feature:project:personal:
|
||||||
** TODO [#B] Fix task app to only use one tag for the context a task was done in and allow configurable contexts by user profile :personal:vrobbler:feature:tasks:project:
|
|
||||||
** TODO [#B] Add CSV endpoint for book scrobbles that LibraryThing can ingest :personal:project:books:feature:export:
|
** TODO [#B] Add CSV endpoint for book scrobbles that LibraryThing can ingest :personal:project:books:feature:export:
|
||||||
https://app.todoist.com/app/task/add-a-csv-endpoint-for-users-book-reads-that-library-thing-can-ingest-6X7QPMRp265xMXqg#comment-6X7QrXq6gJjMP4hg
|
https://app.todoist.com/app/task/add-a-csv-endpoint-for-users-book-reads-that-library-thing-can-ingest-6X7QPMRp265xMXqg#comment-6X7QrXq6gJjMP4hg
|
||||||
** TODO [#C] Fix bug where podcast scrobbling creates duplicate Podcast :project:vrobbler:scrobbling:podcasts:bug:personal:
|
** TODO [#C] Fix bug where podcast scrobbling creates duplicate Podcast :project:vrobbler:scrobbling:podcasts:bug:personal:
|
||||||
@ -352,8 +352,13 @@ it's annoying.
|
|||||||
** TODO [#C] User should be able to enable auto trail tracking via amail reader with Garmin LiveTrack URLs :vrobbler:trails:project:feature:personal:
|
** TODO [#C] User should be able to enable auto trail tracking via amail reader with Garmin LiveTrack URLs :vrobbler:trails:project:feature:personal:
|
||||||
** TODO [#C] Allow users to see tasks on calendar view :vrobbler:personal:project:templates:feature:
|
** TODO [#C] Allow users to see tasks on calendar view :vrobbler:personal:project:templates:feature:
|
||||||
https://codepen.io/oliviale/pen/QYqybo
|
https://codepen.io/oliviale/pen/QYqybo
|
||||||
** TODO [#C] Come pu with a possible flow using WebDAV and super-productivity for tasks :personal:feature:project:vrobbler:tasks:
|
** TODO [#C] Come up with a possible flow using WebDAV and super-productivity for tasks :personal:feature:project:vrobbler:tasks:
|
||||||
* Version 17.0
|
* Version 17.1 [1/1]
|
||||||
|
** DONE [#B] Fix task app to only use one tag for the context a task was done in and allow configurable contexts by user profile :personal:vrobbler:feature:tasks:project:
|
||||||
|
:PROPERTIES:
|
||||||
|
:ID: 1ec89c57-0bb8-3401-33bd-ba65127ed36b
|
||||||
|
:END:
|
||||||
|
* Version 17.0 [6/6]
|
||||||
** DONE [#A] Fix bug in new task label lookup for Emacs/Org-mode :vrobbler:bug:tasks:
|
** DONE [#A] Fix bug in new task label lookup for Emacs/Org-mode :vrobbler:bug:tasks:
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:ID: 683fb109-dfc4-85e4-80f0-ea618434f61e
|
:ID: 683fb109-dfc4-85e4-80f0-ea618434f61e
|
||||||
|
|||||||
@ -56,7 +56,7 @@ class UserProfile(TimeStampedModel):
|
|||||||
return pytz.timezone(self.timezone)
|
return pytz.timezone(self.timezone)
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def task_context_tags(self) -> list:
|
def task_context_tags(self) -> list[str]:
|
||||||
tag_list = [
|
tag_list = [
|
||||||
t.strip().capitalize()
|
t.strip().capitalize()
|
||||||
for t in self.task_context_tags_str.split(",")
|
for t in self.task_context_tags_str.split(",")
|
||||||
|
|||||||
@ -135,6 +135,7 @@ class BookLogData(LongPlayLogData):
|
|||||||
page_start: Optional[int] = None
|
page_start: Optional[int] = None
|
||||||
page_end: Optional[int] = None
|
page_end: Optional[int] = None
|
||||||
serial_scrobble_id: Optional[int] = None
|
serial_scrobble_id: Optional[int] = None
|
||||||
|
details: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
@ -31,12 +31,9 @@ from tasks.models import Task
|
|||||||
from videogames.howlongtobeat import lookup_game_from_hltb
|
from videogames.howlongtobeat import lookup_game_from_hltb
|
||||||
from videogames.models import VideoGame
|
from videogames.models import VideoGame
|
||||||
from videos.models import Video
|
from videos.models import Video
|
||||||
|
from tasks.utils import get_title_from_labels
|
||||||
from webpages.models import WebPage
|
from webpages.models import WebPage
|
||||||
|
|
||||||
from vrobbler.apps.tasks.constants import (
|
|
||||||
TODOIST_TITLE_LABELS
|
|
||||||
)
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -412,23 +409,9 @@ def todoist_scrobble_task(
|
|||||||
user_id: int,
|
user_id: int,
|
||||||
started: bool = False,
|
started: bool = False,
|
||||||
stopped: bool = False,
|
stopped: bool = False,
|
||||||
|
user_context_list: list[str] = [],
|
||||||
) -> Scrobble:
|
) -> Scrobble:
|
||||||
|
title = get_title_from_labels(todoist_task.get("todoist_label_list", []), user_context_list)
|
||||||
prefix = ""
|
|
||||||
suffix = ""
|
|
||||||
# TODO look up the user profile and instead of checking PREFIX/SUFFIX, check against
|
|
||||||
# user.profile.task_context_tags which will result in context-based tag titles
|
|
||||||
# We'd also have to migrate existing tasks to the new context based ones (maybe)
|
|
||||||
for label in todoist_task["todoist_label_list"]:
|
|
||||||
if label in TODOIST_TITLE_LABELS:
|
|
||||||
title = label
|
|
||||||
|
|
||||||
if not prefix and suffix:
|
|
||||||
logger.warning(
|
|
||||||
"Missing a prefix and suffix tag for task",
|
|
||||||
extra={"todoist_scrobble_task": todoist_task},
|
|
||||||
)
|
|
||||||
|
|
||||||
task = Task.find_or_create(title)
|
task = Task.find_or_create(title)
|
||||||
|
|
||||||
timestamp = pendulum.parse(todoist_task.get("updated_at", timezone.now()))
|
timestamp = pendulum.parse(todoist_task.get("updated_at", timezone.now()))
|
||||||
@ -550,23 +533,11 @@ def emacs_scrobble_task(
|
|||||||
user_id: int,
|
user_id: int,
|
||||||
started: bool = False,
|
started: bool = False,
|
||||||
stopped: bool = False,
|
stopped: bool = False,
|
||||||
|
user_context_list: list[str] = [],
|
||||||
) -> Scrobble | None:
|
) -> Scrobble | None:
|
||||||
|
|
||||||
prefix = ""
|
|
||||||
suffix = ""
|
|
||||||
|
|
||||||
source_id = task_data.get("source_id")
|
source_id = task_data.get("source_id")
|
||||||
for label in task_data.get("labels", []):
|
title = get_title_from_labels(task_data.get("labels", []), user_context_list)
|
||||||
if label in TODOIST_TITLE_LABELS:
|
|
||||||
title = label
|
|
||||||
|
|
||||||
if not prefix and not suffix:
|
|
||||||
logger.warning(
|
|
||||||
"Missing a prefix and suffix tag for task",
|
|
||||||
extra={"emacs_scrobble_task": task_data},
|
|
||||||
)
|
|
||||||
|
|
||||||
title = " ".join([prefix.capitalize(), suffix.capitalize()])
|
|
||||||
task = Task.find_or_create(title)
|
task = Task.find_or_create(title)
|
||||||
|
|
||||||
timestamp = pendulum.parse(task_data.get("updated_at", timezone.now()))
|
timestamp = pendulum.parse(task_data.get("updated_at", timezone.now()))
|
||||||
|
|||||||
@ -1,15 +0,0 @@
|
|||||||
TODOIST_TITLE_LABELS = [
|
|
||||||
"bug",
|
|
||||||
"feature",
|
|
||||||
"errand",
|
|
||||||
"chore",
|
|
||||||
"admin",
|
|
||||||
"computer",
|
|
||||||
"farm",
|
|
||||||
"baking",
|
|
||||||
"meeting",
|
|
||||||
"habit",
|
|
||||||
"research",
|
|
||||||
"exercise",
|
|
||||||
"lifeevent",
|
|
||||||
]
|
|
||||||
22
vrobbler/apps/tasks/utils.py
Normal file
22
vrobbler/apps/tasks/utils.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
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
|
||||||
@ -71,9 +71,9 @@ def todoist_webhook(request):
|
|||||||
"updated_at": task_data.get("updated_at"),
|
"updated_at": task_data.get("updated_at"),
|
||||||
"details": task_data.get("description"),
|
"details": task_data.get("description"),
|
||||||
"notes": event_data.get("content"),
|
"notes": event_data.get("content"),
|
||||||
"is_deleted": True
|
"is_deleted": (
|
||||||
if event_data.get("is_deleted") == "true"
|
True if event_data.get("is_deleted") == "true" else False
|
||||||
else False,
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_added and not todoist_note) or (is_updated and not todoist_task):
|
if (is_added and not todoist_note) or (is_updated and not todoist_task):
|
||||||
@ -90,16 +90,17 @@ def todoist_webhook(request):
|
|||||||
)
|
)
|
||||||
return Response({}, status=status.HTTP_304_NOT_MODIFIED)
|
return Response({}, status=status.HTTP_304_NOT_MODIFIED)
|
||||||
|
|
||||||
user_id = (
|
user_profile = UserProfile.objects.filter(
|
||||||
UserProfile.objects.filter(todoist_user_id=post_data.get("user_id"))
|
todoist_user_id=post_data.get("user_id", None)
|
||||||
.first()
|
).first()
|
||||||
.user_id
|
|
||||||
)
|
|
||||||
|
|
||||||
scrobble = None
|
scrobble = None
|
||||||
if todoist_task:
|
if todoist_task:
|
||||||
scrobble = todoist_scrobble_task(
|
scrobble = todoist_scrobble_task(
|
||||||
todoist_task, user_id, stopped=task_stopped
|
todoist_task,
|
||||||
|
user_profile.user_id,
|
||||||
|
stopped=task_stopped,
|
||||||
|
user_context_list=user_profile.task_context_tags,
|
||||||
)
|
)
|
||||||
|
|
||||||
if todoist_note:
|
if todoist_note:
|
||||||
@ -143,10 +144,16 @@ def emacs_webhook(request):
|
|||||||
if not user_id:
|
if not user_id:
|
||||||
user_id = 1
|
user_id = 1
|
||||||
|
|
||||||
|
user_profile = UserProfile.objects.filter(user_id=user_id).first()
|
||||||
|
|
||||||
scrobble = None
|
scrobble = None
|
||||||
if post_data.get("source_id"):
|
if post_data.get("source_id"):
|
||||||
scrobble = emacs_scrobble_task(
|
scrobble = emacs_scrobble_task(
|
||||||
post_data, user_id, started=task_in_progress, stopped=task_stopped
|
post_data,
|
||||||
|
user_id,
|
||||||
|
started=task_in_progress,
|
||||||
|
stopped=task_stopped,
|
||||||
|
user_context_list=user_profile.task_context_tags,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not scrobble:
|
if not scrobble:
|
||||||
|
|||||||
Reference in New Issue
Block a user