本番デプロイ設定: SSL, Kamal, API環境変数化, テスト修正
This commit is contained in:
@@ -7,8 +7,8 @@ class BoardPostsController < ApplicationController
|
||||
before_action :set_current_participant
|
||||
|
||||
def create
|
||||
# 参加チェック
|
||||
unless @board.member?(@current_participant) && @game.status == "in_progress"
|
||||
# 参加チェック(国選択フェーズでも共通掲示板への投稿を許可)
|
||||
unless @board.member?(@current_participant) && @game.status.in?(%w[power_selection in_progress])
|
||||
return redirect_to game_board_path(@game, @board), alert: "投稿権限がありません"
|
||||
end
|
||||
|
||||
|
||||
@@ -22,14 +22,19 @@ class BoardsController < ApplicationController
|
||||
else
|
||||
return redirect_to game_path(@game), alert: "参加者ではないためアクセスできません" unless @current_participant
|
||||
|
||||
# 進行中:参加中の掲示板のみ(eager load で N+1 防止)
|
||||
@boards = @current_participant.boards.includes(:participants, :board_posts, :board_memberships).order(created_at: :desc)
|
||||
# 共通掲示板のフォールバック
|
||||
global_board = @game.boards.global.first
|
||||
if global_board && !@boards.include?(global_board)
|
||||
@boards = [ global_board ] + @boards
|
||||
if @game.status == "power_selection"
|
||||
# 国選択フェーズ:共通掲示板のみ表示
|
||||
@boards = @game.boards.global.includes(:participants, :board_posts, :board_memberships).to_a
|
||||
else
|
||||
# 進行中:参加中の掲示板のみ(eager load で N+1 防止)
|
||||
@boards = @current_participant.boards.includes(:participants, :board_posts, :board_memberships).order(created_at: :desc)
|
||||
# 共通掲示板のフォールバック
|
||||
global_board = @game.boards.global.first
|
||||
if global_board && !@boards.include?(global_board)
|
||||
@boards = [ global_board ] + @boards
|
||||
end
|
||||
@boards = @boards.sort_by { |b| b.global? ? 0 : 1 }
|
||||
end
|
||||
@boards = @boards.sort_by { |b| b.global? ? 0 : 1 }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -70,11 +75,11 @@ class BoardsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
@posts = @board.board_posts.includes(:participant).order(created_at: :desc)
|
||||
@posts = @board.board_posts.includes(participant: :user).order(created_at: :desc)
|
||||
@proposals = @board.board_proposals.includes(:proposer).order(created_at: :desc)
|
||||
@new_post = BoardPost.new
|
||||
@new_proposal = BoardProposal.new
|
||||
@active_members = @board.active_memberships.includes(:participant).map(&:participant)
|
||||
@active_members = @board.active_memberships.includes(participant: :user).map(&:participant)
|
||||
|
||||
# メンバー追加用:招待可能なプレイヤー一覧
|
||||
if @board.negotiation? && !@board.history_mode?
|
||||
|
||||
@@ -75,8 +75,11 @@ class GamesController < ApplicationController
|
||||
# 全7カ国(固定)
|
||||
powers = %w[AUSTRIA ENGLAND FRANCE GERMANY ITALY RUSSIA TURKEY]
|
||||
|
||||
# N+1 防止のためparticipantsをキャッシュ
|
||||
participants_cache = @game.participants.includes(:user).index_by(&:power)
|
||||
|
||||
@country_statuses = powers.map do |power|
|
||||
participant = @game.participants.find_by(power: power)
|
||||
participant = participants_cache[power]
|
||||
# 終了済みなら全員完了扱い、そうでなければターンごとの提出状況
|
||||
submitted = @game_finished ? true : @display_turn.orders_submitted_for?(power)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user