<commit_before>module Api::V1
  class ContestsController < Api::ApiController
    def index
      contests = Contest.order("begins DESC")

      if params[:current_only] == "1"
        contests = contests.current
      end

      if timetable_filter = params[:timetables_public]
        filter_value = timetable_filter == "1" ? true : false
        contests = contests.with_timetables_public(filter_value)
      end

      @contests = contests
    end
  end
end<commit_msg>Reduce n+1 queries for API /contests response<commit_after>module Api::V1
  class ContestsController < Api::ApiController
    def index
      contests = Contest.includes(:host).order("begins DESC")

      if params[:current_only] == "1"
        contests = contests.current
      end

      if timetable_filter = params[:timetables_public]
        filter_value = timetable_filter == "1" ? true : false
        contests = contests.with_timetables_public(filter_value)
      end

      @contests = contests
    end
  end
end
{'fraction_non_alphanumeric': 0.08651911468812877, 'fraction_numerical': 0.007042253521126761, 'mean_word_length': 2.995983935742972, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6430034', 'n_tokens_mistral': 310, 'n_tokens_neox': 293, 'n_words': 69}