cleanup notifications

This commit is contained in:
simon 2023-03-30 18:20:53 +07:00
parent db0ade203a
commit 2a0a04ac65
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
4 changed files with 9 additions and 2 deletions

View File

@ -242,6 +242,9 @@ class PendingList(PendingIndex):
total = len(self.missing_videos)
for idx, (youtube_id, vid_type) in enumerate(self.missing_videos):
if self.task and self.task.is_stopped():
break
print(f"{youtube_id}: [{idx + 1}/{total}]: add to queue")
self._notify_add(idx, total)
video_details = self.get_youtube_details(youtube_id, vid_type)

View File

@ -206,5 +206,4 @@ class CommentList:
"""send notification on task"""
message = [f"Add comments for new videos {idx + 1}/{total_videos}"]
progress = (idx + 1) / total_videos
title = "Index Comments"
self.task.send_progress(message, progress=progress, title=title)
self.task.send_progress(message, progress=progress)

View File

@ -72,6 +72,9 @@ class TaskManager:
run at startup to recover from hard reset
"""
all_results = self.get_all_results()
if not all_results:
return
for result in all_results:
if result.get("status") == "PENDING":
result["status"] = "FAILED"

View File

@ -63,6 +63,7 @@ class BaseTask(Task):
"extract_download": {
"title": "Add to download queue",
"group": "download:add",
"api-stop": True,
},
"check_reindex": {
"title": "Reindex Documents",
@ -195,6 +196,7 @@ def download_pending(self, from_queue=True):
@shared_task(name="extract_download", bind=True, base=BaseTask)
def extrac_dl(self, youtube_ids):
"""parse list passed and add to pending"""
TaskManager().init(self)
pending_handler = PendingList(youtube_ids=youtube_ids, task=self)
pending_handler.parse_url_list()
pending_handler.add_to_pending()