<commit_before>class Radars::BlipsController < ApplicationController
  def new
    blip = radar.new_blip({})
    render locals: { quadrants: quadrants, rings: rings, blip: blip, radar: radar, blips: blips }
  end

  def create
    blip = radar.new_blip(blip_params)
    if blip.save
      redirect_to radar
    else
      render 'new', locals: { quadrants: quadrants, rings: rings, blip: blip, radar: radar, blips: blips }
    end
  end

  def show
    render locals: { blip: blip }
  end

  def edit
    # TODO should not be able to edit blip name
    render locals: { quadrants: quadrants, rings: rings, blip: blip, blips: blips }
  end

  def update
    if blip.update(blip_params)
      redirect_to radar, notice: "Blip updated"
    else
      render 'edit', locals: { quadrants: quadrants, rings: rings, blip: blip, radar: radar, blips: blips }
    end
  end

  def destroy
    blip.destroy!
    redirect_to radar
    # can I use @blip.radar?
  end

  private

  def blip_params
    params.require(:blip).permit(:name, :quadrant, :ring, :notes)
  end

  def radar
    @radar = current_user.find_radar(params[:radar_id])
  end

  def blip
    @blip = radar.find_blip(params[:id])
  end

  def quadrants
    Blip::QUADRANTS.inject({}) do |result, item|
      result[item.titleize] = item
      result
    end
  end

  def rings
    Blip::RINGS.inject({}) do |result, item|
      result[item.titleize] = item
      result
    end
  end

  def blips
    Blip.order(:name).map(&:name)
  end
end
<commit_msg>Remove ivars<commit_after>class Radars::BlipsController < ApplicationController
  def new
    @blip = radar.new_blip({})
    locals
  end

  def create
    @blip = radar.new_blip(blip_params)
    if blip.save
      redirect_to radar
    else
      locals 'new'
    end
  end

  def show
    locals
  end

  def edit
    locals
  end

  def update
    if blip.update(blip_params)
      redirect_to radar, notice: "Blip updated"
    else
      locals 'edit'
    end
  end

  def destroy
    blip.destroy!
    redirect_to radar
  end

  private

  def locals(template = nil)
    render template, locals: { quadrants: quadrants, rings: rings, blip: blip, blips: blips }
  end

  def blip_params
    params.require(:blip).permit(:name, :quadrant, :ring, :notes)
  end

  def radar
    @radar ||= current_user.find_radar(params[:radar_id])
  end

  def blip
    @blip ||= radar.find_blip(params[:id])
  end

  def quadrants
    Blip::QUADRANTS.inject({}) do |result, item|
      result[item.titleize] = item
      result
    end
  end

  def rings
    Blip::RINGS.inject({}) do |result, item|
      result[item.titleize] = item
      result
    end
  end

  def blips
    Blip.order(:name).map(&:name)
  end
end

{'fraction_non_alphanumeric': 0.0998894213048286, 'fraction_numerical': 0.0, 'mean_word_length': 2.717808219178082, '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': '3213568', 'n_tokens_mistral': 975, 'n_tokens_neox': 956, 'n_words': 264}