<commit_before>class GiftsController < ApplicationController
  def index
    @gifts = Gift.where(user_id: 1)

    render json: @gifts
  end

  def create
    @gift = Gift.new(
    user_id: params[:user_id],
    amount: params[:amount].to_i,
    charity: params[:charity],
    team: params[:team]
    )

    if @gift.save
      render json: @gift, status: :created, location: nil
    else
      render json: @gift.errors, status: :unprocessable_entity
    end
  end

  def show
    @gift = Gift.find(params[:id])

    render json: @gift
  end

  def totals
    @gift_totals = get_totals(Gift.where(team: '49ers'), Gift.where(team: 'Packers'))

    render json: @gift_totals
  end

  def get_totals(team1, team2)
    totals = []

    totals.push(team1.inject(0) { |total, element| total + element.amount })
    totals.push(team2.inject(0) { |total, element| total + element.amount })

    return totals
  end
end
<commit_msg>Add icon field to params on gift post route<commit_after>class GiftsController < ApplicationController
  def index
    @gifts = Gift.where(user_id: 1)

    render json: @gifts
  end

  def create
    @user = User.find(params[:user_id])
    @gift = Gift.new(
      user_id: params[:user_id],
      amount: params[:amount].to_i,
      charity: params[:charity],
      team: params[:team],
      icon: params[:icon]
    )

    if @gift.save
      render json: @user
    else
      render json: @user
    end
  end

  def show
    @gift = Gift.find(params[:id])

    render json: @gift
  end

  def totals
    @gift_totals = get_totals(Gift.where(team: '49ers'), Gift.where(team: 'Packers'))

    render json: @gift_totals
  end

  def get_totals(team1, team2)
    totals = []

    totals.push(team1.inject(0) { |total, element| total + element.amount })
    totals.push(team2.inject(0) { |total, element| total + element.amount })

    return totals
  end
end

{'fraction_non_alphanumeric': 0.12234042553191489, 'fraction_numerical': 0.009574468085106383, 'mean_word_length': 2.9683544303797467, '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': '4494050', 'n_tokens_mistral': 688, 'n_tokens_neox': 657, 'n_words': 162}