<commit_before>module WhoToBlame
  class SnapshotsController < WhoToBlame::ApplicationController
    def show
      date = date_from_params

      footprints = db_manager.footprints(date)
      snapshot = WhoToBlame::Snapshot.new(date, footprints)

      respond_to do |format|
        format.json { render json: snapshot }
      end
    end

    def create
      num_steps = params[:num_steps].to_i
      step = params[:step].to_i
      end_date = date_from_params
      data_builder = WhoToBlame::DataBuilder.new(['rb'])
      snapshots = data_builder.snapshots(end_date, num_steps, step)
      DatabaseManager.new.clear!.load_snapshots!(snapshots)

      respond_to do |format|
        format.json { render json: snapshots.last }
      end
    end

    private

    def date_from_params
      Date.new(params[:year].to_i, params[:month].to_i, params[:day].to_i)
    end

    def asking_for_latest
      params[:id] == 'latest'
    end
  end<commit_msg>Fixing specs<commit_after>module WhoToBlame
  class SnapshotsController < WhoToBlame::ApplicationController
    def show
      date = date_from_params

      footprints = DatabaseManager.new.footprints(date)
      snapshot = WhoToBlame::Snapshot.new(date, footprints)

      respond_to do |format|
        format.json { render json: snapshot }
      end
    end

    def create
      num_steps = params[:num_steps].to_i
      step = params[:step].to_i
      end_date = date_from_params
      data_builder = WhoToBlame::DataBuilder.new(['rb'])
      snapshots = data_builder.snapshots(end_date, num_steps, step)
      DatabaseManager.new.clear!.load_snapshots!(snapshots)

      respond_to do |format|
        format.json { render json: snapshots.last }
      end
    end

    private

    def date_from_params
      Date.new(params[:year].to_i, params[:month].to_i, params[:day].to_i)
    end

    def asking_for_latest
      params[:id] == 'latest'
    end
  end
{'fraction_non_alphanumeric': 0.09332638164754953, 'fraction_numerical': 0.0, 'mean_word_length': 2.940451745379877, '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': '6810705', 'n_tokens_mistral': 609, 'n_tokens_neox': 591, 'n_words': 120}