Skip to content

Commit d813c11

Browse files
committed
feat: add update_user_mark_as_solution method to mark posts as solutions in the database
1 parent 22942b7 commit d813c11

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

src/data/forum/post_assist.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from asyncpg import Pool
2-
from datetime import datetime
32

43

54
class AcceptedSolution:
@@ -370,6 +369,40 @@ async def mark_as_solution(
370369
user_id,
371370
)
372371

372+
async def update_user_mark_as_solution(
373+
self,
374+
post_assist_id: int,
375+
thread_id: int,
376+
message_id: int,
377+
user_id: int,
378+
new_user_id: int,
379+
):
380+
"""Marks a post as a solution."""
381+
382+
async with self._pool.acquire() as conn:
383+
conn: Pool
384+
385+
await conn.execute(
386+
"""
387+
UPDATE
388+
pph_post_assist_config_accept_solutions
389+
SET
390+
message_id = $1,
391+
user_id = $2
392+
WHERE
393+
post_assist_config_id = $3
394+
AND user_id = $4
395+
AND thread_id = $5;
396+
""",
397+
message_id,
398+
new_user_id,
399+
post_assist_id,
400+
user_id,
401+
thread_id,
402+
)
403+
404+
return True
405+
373406
async def get_accepted_solution(self, thread_id: int) -> AcceptedSolution | None:
374407
"""Gets the accepted solution for a forum."""
375408

0 commit comments

Comments
 (0)