<commit_before>class Api::ActionPlansController < Api::ApplicationController
  include HasOrders

  before_action :authenticate_user!
  load_and_authorize_resource

  def index
    set_seed

    action_plans = @current_order == "recommended" ? Recommender.new(current_user).action_plans : ActionPlan.all

    @action_plans = ResourceFilter.new(params, user: current_user)
      .filter_collection(action_plans.includes(:category, :subcategory))
      .send("sort_by_created_at")
      .page(params[:page])
      .per(15)

    respond_to do |format|
      format.json { 
        render json: @action_plans, meta: {
          seed: @random_seed,
          current_page: @action_plans.current_page,
          next_page: @action_plans.next_page,
          prev_page: @action_plans.prev_page,
          total_pages: @action_plans.total_pages,
          total_count: @action_plans.total_count
        }
      }
    end
  end

  def show
    render json: @action_plan
  end

  def proposals
    @proposals = @action_plan.proposals
    render json: { proposals: @proposals }
  end

  private<commit_msg>Fix action plans' related proposals<commit_after>class Api::ActionPlansController < Api::ApplicationController
  include HasOrders

  before_action :authenticate_user!
  load_and_authorize_resource

  def index
    set_seed

    action_plans = @current_order == "recommended" ? Recommender.new(current_user).action_plans : ActionPlan.all

    @action_plans = ResourceFilter.new(params, user: current_user)
      .filter_collection(action_plans.includes(:category, :subcategory))
      .send("sort_by_created_at")
      .page(params[:page])
      .per(15)

    respond_to do |format|
      format.json { 
        render json: @action_plans, meta: {
          seed: @random_seed,
          current_page: @action_plans.current_page,
          next_page: @action_plans.next_page,
          prev_page: @action_plans.prev_page,
          total_pages: @action_plans.total_pages,
          total_count: @action_plans.total_count
        }
      }
    end
  end

  def show
    render json: @action_plan
  end

  def proposals
    @proposals = @action_plan.proposals
    render json: @proposals, root: 'proposals'
  end

  private
{'fraction_non_alphanumeric': 0.08844765342960288, 'fraction_numerical': 0.0018050541516245488, 'mean_word_length': 3.167293233082707, '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': '5554918', 'n_tokens_mistral': 724, 'n_tokens_neox': 703, 'n_words': 130}