json.count @count
json.competitions do
  json.array! @competitions.each do |competition|
    json.extract! competition, :id, :identifier, :name, :sub_title, :bonus, :description, :mode

    json.competition_status competition.competition_status
    json.visits_count competition.visits
    course = competition.competition_mode_setting&.course if competition.mode == 2
    member_count = course ? course.students.count : (@member_count_map&.fetch(competition.id, 0) || competition.team_members.count)
    json.member_count member_count.zero? ? 268 : member_count

    json.image url_to_avatar(competition)
    json.published competition.published?
    json.nearly_published competition.published_at.present?
    json.single_stage (@stage_count_map&.fetch(competition.id, 0) || competition.competition_stages.count) == 1

    json.start_time competition.start_time&.strftime("%Y-%m-%d")
    json.end_time competition.end_time&.strftime("%Y-%m-%d")
    json.enroll_end_time competition.enroll_end_time&.strftime("%Y-%m-%d %H:%M:%S")

    json.sponsor_schools competition.sponsor_schools_name
    # section = competition.current_stage_section
    # if section
    #   json.current_stage do
    #
    #     json.name section.competition_stage.name
    #     json.start_time section.display_start_time
    #     json.end_time section.display_end_time
    #   end
    # end

    json.permission do
      json.editable current_user.admin_or_business? || competition.manager?(current_user)
    end
  end
end