<commit_before>module Houston
  module Roadmaps
    class RoadmapMilestonesController < RoadmapsController
      layout "houston/roadmaps/application"
      before_filter :find_roadmap


      def index
        authorize! :read, Roadmap
        render json: Houston::Roadmaps::RoadmapMilestonePresenter.new(@roadmap.milestones)
      end


      def update
        authorize! :update, @roadmap

        @roadmap.commits.create!(
          user: current_user,
          message: params[:message],
          milestone_changes: params.fetch(:roadmap, {}).values)

        head :ok
      rescue ActiveRecord::RecordInvalid
        render json: $!.record.errors, status: 422
      end


    private

      def find_roadmap
        @roadmap = Roadmap.find params[:id]
      end

    end
  end
end
<commit_msg>[skip] Eager-loaded project before presenting roadmap milestones (1m)<commit_after>module Houston
  module Roadmaps
    class RoadmapMilestonesController < RoadmapsController
      layout "houston/roadmaps/application"
      before_filter :find_roadmap


      def index
        authorize! :read, Roadmap
        render json: Houston::Roadmaps::RoadmapMilestonePresenter.new(
          @roadmap.milestones.preload(milestone: :project))
      end


      def update
        authorize! :update, @roadmap

        @roadmap.commits.create!(
          user: current_user,
          message: params[:message],
          milestone_changes: params.fetch(:roadmap, {}).values)

        head :ok
      rescue ActiveRecord::RecordInvalid
        render json: $!.record.errors, status: 422
      end


    private

      def find_roadmap
        @roadmap = Roadmap.find params[:id]
      end

    end
  end
end

{'fraction_non_alphanumeric': 0.08108108108108109, 'fraction_numerical': 0.004112808460634548, 'mean_word_length': 2.5041152263374484, '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': '3633006', 'n_tokens_mistral': 501, 'n_tokens_neox': 463, 'n_words': 115}