diff --git a/reader/views.py b/reader/views.py index 0764241743..2e5e314cb5 100644 --- a/reader/views.py +++ b/reader/views.py @@ -1550,7 +1550,8 @@ def internal_do_post(): skip_links = bool(int(request.POST.get("skip_links", 0))) count_after = int(request.POST.get("count_after", 0)) version_change = VersionChange(raw_version=data, uid=request.user.id, method=method, patch=patch, count_after=count_after, skip_links=skip_links) - return save_changes([asdict(version_change)], save_version, method) + task_title = f'Version Post: {data["title"]} / {data["versionTitle"]} / {data["language"]}' + return save_changes([asdict(version_change)], save_version, method, task_title) if request.method == "POST": patch = False @@ -1985,7 +1986,8 @@ def _internal_do_post(request, obj, uid, method, skip_check, override_preciselin link["_override_preciselink"] = True links.append(asdict(LinkChange(raw_link=link, uid=uid, method=method))) - return save_changes(links, save_link, method) + task_title = f'Links Post. First link: {obj[0]["refs"][0]}-{obj[0]["refs"][1]}' + return save_changes(links, save_link, method, task_title) def _internal_do_delete(request, link_id_or_ref, uid): obj = tracker.delete(uid, Link, link_id_or_ref, callback=revarnish_link) diff --git a/sefaria/helper/texts/tasks.py b/sefaria/helper/texts/tasks.py index f114b70cb5..b5696d8a1c 100644 --- a/sefaria/helper/texts/tasks.py +++ b/sefaria/helper/texts/tasks.py @@ -24,11 +24,11 @@ def should_run_with_celery(from_api): return CELERY_ENABLED and from_api -def save_changes(changes, func, method): +def save_changes(changes, func, method, task_title=''): if should_run_with_celery(method == 'API'): main_task_id = str(uuid.uuid4()) tasks = [save_change.s(func.__name__, c).set(queue=CELERY_QUEUES['tasks']) for c in changes] - job = chord(tasks, inform.s(main_task_id=main_task_id).set(queue=CELERY_QUEUES['tasks']))(task_id=main_task_id) + job = chord(tasks, inform.s(main_task_id=main_task_id, task_title=task_title).set(queue=CELERY_QUEUES['tasks']))(task_id=main_task_id) tasks_ids = [task.id for task in job.parent.results] return celeryResponse(job.id, tasks_ids) else: @@ -59,8 +59,8 @@ def save_change(func_name, raw_history_change): return repr(e) @app.task(name="web.inform", acks_late=True) -def inform(results, main_task_id): - title = f'Results for celery main task with id {main_task_id}' +def inform(results, main_task_id, task_title): + title = f'{task_title} (celery main task id {main_task_id})' results = '\n'.join([f'{k}: {v}.' for k, v in Counter(results).items()]) send_message('#engineering-signal', 'Text Upload', title, results, icon_emoji=':leafy_green:')