|
|
@ -123,19 +123,19 @@ class Competitions::CompetitionsController < Competitions::BaseController
|
|
|
|
@stage = @competition.competition_stages.take
|
|
|
|
@stage = @competition.competition_stages.take
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@records = @competition.competition_teams.joins(:competition_scores).where(competition_scores: {competition_stage_id: @stage&.id.to_i})
|
|
|
|
@all_records = @competition.competition_teams.joins(:competition_scores).where(competition_scores: {competition_stage_id: @stage&.id.to_i})
|
|
|
|
.select("competition_teams.*, score, cost_time").order("score desc, cost_time desc")
|
|
|
|
.select("competition_teams.*, score, cost_time").order("score desc, cost_time desc")
|
|
|
|
|
|
|
|
|
|
|
|
current_team_ids = @competition.team_members.where(user_id: current_user.id).pluck(:competition_team_id).uniq
|
|
|
|
current_team_ids = @competition.team_members.where(user_id: current_user.id).pluck(:competition_team_id).uniq
|
|
|
|
@user_ranks = @records.select{|com_team| current_team_ids.include?(com_team.id)}
|
|
|
|
@user_ranks = @all_records.select{|com_team| current_team_ids.include?(com_team.id)}
|
|
|
|
@records = @records.where("score > 0")
|
|
|
|
@records = @all_records.where("score > 0")
|
|
|
|
@record_ids = @records.pluck(:id)
|
|
|
|
@record_ids = @records.pluck(:id)
|
|
|
|
if params[:format] == "xlsx"
|
|
|
|
if params[:format] == "xlsx"
|
|
|
|
@records = @records.includes(user: [user_extension: :school], team_members: :user)
|
|
|
|
@records = @records.includes(user: [user_extension: :school], team_members: :user)
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.xlsx{
|
|
|
|
format.xlsx{
|
|
|
|
set_export_cookies
|
|
|
|
set_export_cookies
|
|
|
|
chart_to_xlsx(@records, @competition)
|
|
|
|
chart_to_xlsx(@all_records, @competition)
|
|
|
|
exercise_export_name = "#{@competition.name}比赛成绩"
|
|
|
|
exercise_export_name = "#{@competition.name}比赛成绩"
|
|
|
|
render xlsx: "#{exercise_export_name.strip}",template: "competitions/competitions/chart_list.xlsx.axlsx",locals:
|
|
|
|
render xlsx: "#{exercise_export_name.strip}",template: "competitions/competitions/chart_list.xlsx.axlsx",locals:
|
|
|
|
{table_columns: @competition_head_cells, chart_lists: @competition_cells_column}
|
|
|
|
{table_columns: @competition_head_cells, chart_lists: @competition_cells_column}
|
|
|
|