From 3a96cb062b498e1569892ec9543a8de998c08065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=B6pf?= Date: Thu, 22 Dec 2022 18:58:19 +0100 Subject: [PATCH] fix duplicate ack_task api-calls --- backend/oasst_backend/api/v1/tasks.py | 2 +- bot/task_handlers.py | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/backend/oasst_backend/api/v1/tasks.py b/backend/oasst_backend/api/v1/tasks.py index dac2a9bd..7ec5aa96 100644 --- a/backend/oasst_backend/api/v1/tasks.py +++ b/backend/oasst_backend/api/v1/tasks.py @@ -169,8 +169,8 @@ def acknowledge_task( pr = PromptRepository(db, api_client, user=None) # here we store the post id in the database for the task - pr.bind_frontend_post_id(task_id=task_id, post_id=ack_request.post_id) logger.info(f"Frontend acknowledges task {task_id=}, {ack_request=}.") + pr.bind_frontend_post_id(task_id=task_id, post_id=ack_request.post_id) except Exception: logger.exception("Failed to acknowledge task.") diff --git a/bot/task_handlers.py b/bot/task_handlers.py index 261860ab..6f38fa88 100644 --- a/bot/task_handlers.py +++ b/bot/task_handlers.py @@ -86,13 +86,11 @@ class SummarizeStoryHandler(ChannelTaskBase): thread_name: str = "Summaries" async def send_first_message(self) -> discord.message: - expiry_time = discord_timestamp(self.expiry_date, DiscordTimestampStyle.long_time) expiry_relatve = discord_timestamp(self.expiry_date, DiscordTimestampStyle.relative_time) msg = await self.bot.post_template( "task_summarize_story_teaser.msg", task=self.task, expiry_time=expiry_time, expiry_relatve=expiry_relatve ) - self.backend.ack_task(self.task.id, str(msg.id)) return msg async def on_thread_created(self, thread: discord.Thread) -> None: @@ -110,7 +108,6 @@ class InitialPromptHandler(ChannelTaskBase): async def send_first_message(self) -> discord.message: msg = await self.bot.post_template("task_initial_prompt.msg", task=self.task) - self.backend.ack_task(self.task.id, str(msg.id)) return msg async def handler_loop(self): @@ -125,7 +122,6 @@ class UserReplyHandler(ChannelTaskBase): async def send_first_message(self) -> discord.message: msg = await self.bot.post_template("task_user_reply.msg", task=self.task) - self.backend.ack_task(self.task.id, str(msg.id)) return msg async def handler_loop(self): @@ -140,7 +136,6 @@ class AssistantReplyHandler(ChannelTaskBase): async def send_first_message(self) -> discord.message: msg = await self.bot.post_template("task_assistant_reply.msg", task=self.task) - self.backend.ack_task(self.task.id, str(msg.id)) return msg async def handler_loop(self): @@ -160,7 +155,6 @@ class RankInitialPromptsHandler(ChannelTaskBase): async def send_first_message(self) -> discord.message: msg = await self.bot.post_template("task_rank_initial_prompts.msg", task=self.task) - self.backend.ack_task(self.task.id, str(msg.id)) return msg async def handler_loop(self): @@ -176,7 +170,6 @@ class RankConversationsHandler(ChannelTaskBase): async def send_first_message(self) -> discord.message: msg = await self.bot.post_template("task_rank_conversation_replies.msg", task=self.task) - self.backend.ack_task(self.task.id, str(msg.id)) return msg async def handler_loop(self): @@ -215,7 +208,6 @@ class RateSummaryHandler(ChannelTaskBase): async def send_first_message(self) -> discord.message: msg = await self.bot.post("first message") - self.backend.ack_task(self.task.id, str(msg.id)) return msg async def on_thread_created(self, thread: discord.Thread) -> None: