このコミットが含まれているのは:
2026-06-06 20:29:34 +09:00
コミット b1362d327c
7個のファイルの変更138行の追加18行の削除
+26 -3
ファイルの表示
@@ -54,8 +54,11 @@ class TheatresController < ApplicationController
theatre = Theatre.find_by(id: params[:id])
return head :not_found unless theatre
requested_post_id = params[:post_id].to_i
return head :unprocessable_entity if requested_post_id <= 0
skipped = false
conflicted = false
ApplicationRecord.transaction do
theatre.lock!
@@ -64,7 +67,12 @@ class TheatresController < ApplicationController
_1.expires_at = 30.seconds.from_now
}.save!
TheatreSkipVote.find_or_create_by!(theatre:, post: theatre.current_post, user: current_user)
if theatre.current_post_id != requested_post_id
conflicted = true
next
end
TheatreSkipVote.find_or_create_by!(theatre:, post_id: requested_post_id, user: current_user)
vote_status = skip_vote_status(theatre)
if vote_status[:votes_count] >= vote_status[:required_count]
@@ -76,6 +84,8 @@ class TheatresController < ApplicationController
end
theatre.reload
return render json: theatre_info_json(theatre, skipped: false), status: :conflict if conflicted
render json: theatre_info_json(theatre, skipped:)
end
@@ -84,11 +94,24 @@ class TheatresController < ApplicationController
theatre = Theatre.find_by(id: params[:id])
return head :not_found unless theatre
requested_post_id = params[:post_id].to_i
return head :unprocessable_entity if requested_post_id <= 0
if theatre.current_post
TheatreSkipVote.where(theatre:, post: theatre.current_post, user: current_user).delete_all
conflicted = false
theatre.with_lock do
if theatre.current_post
if theatre.current_post_id != requested_post_id
conflicted = true
else
TheatreSkipVote.where(theatre:, post_id: requested_post_id, user: current_user).delete_all
end
end
end
theatre.reload
return render json: theatre_info_json(theatre, skipped: false), status: :conflict if conflicted
render json: theatre_info_json(theatre, skipped: false)
end