<commit_before>class InvestmentsController < ApplicationController
  before_action :set_investment

  def show
  end

  def prices
    @prices = @investment.historical_prices.pluck(:date, :close, 'close * adjustment').map do |p|
      { investment:     @investment.symbol,
        date:           p[0],
        close:          p[1],
        adjusted_close: p[2],
      }
    end

    respond_to do |format|
      format.json { render json: @prices }
    end
  end

  private
  def set_investment
    @investment = Investment.find_by_param(params[:id])
  end
end<commit_msg>Default to 1 year range<commit_after>class InvestmentsController < ApplicationController
  before_action :set_investment

  def show
  end

  def prices
    end_date = params[:end_date] ? Date.parse(params[:end_date]) : Date.today
    start_date = params[:start_date] ? Date.parse(params[:start_date]) : end_date - 365
    @prices = @investment.historical_prices.where(date: start_date..end_date).pluck(:date, :close, 'close * adjustment').map do |p|
      { investment:     @investment.symbol,
        date:           p[0],
        close:          p[1],
        adjusted_close: p[2],
      }
    end

    respond_to do |format|
      format.json { render json: @prices }
    end
  end

  private
  def set_investment
    @investment = Investment.find_by_param(params[:id])
  end
end
{'fraction_non_alphanumeric': 0.10471976401179942, 'fraction_numerical': 0.007374631268436578, 'mean_word_length': 2.8011204481792715, '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': '4542219', 'n_tokens_mistral': 456, 'n_tokens_neox': 426, 'n_words': 97}