Skip to content

Commit

Permalink
refactor(thread-move): wip implement thread move db query function, c…
Browse files Browse the repository at this point in the history
…ontinued
  • Loading branch information
akinsey committed Aug 6, 2024
1 parent 9c509d6 commit df2a2f4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/epochtalk_server/models/thread.ex
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,17 @@ defmodule EpochtalkServer.Models.Thread do

{thread, _thread_meta} = Repo.one(thread_lock_query)

if thread.board_id != board_id do
old_board_lock_query =
from b in Board,
join: mb in MetadataBoard,
on: mb.board_id == b.id,
where: b.id == ^thread.board_id,
select: {b, mb},
lock: "FOR UPDATE"

{old_board, _old_board_meta} = Repo.one(old_board_lock_query)

else
{:error, :invalid_board_id}
end
Expand Down

0 comments on commit df2a2f4

Please sign in to comment.