<commit_before>class Api::PricingTiersController < Api::EventResourceController
  private

  def deserialized_params
    ActiveModelSerializers::Deserialization
      .jsonapi_parse(params)
  end

  # The fields are named different on teh server than the client
  def update_pricing_tier_params
    whitelister = ActionController::Parameters.new(deserialized_params)
    rp = whitelister.permit(
      :increase_by_dollars,
      :date, :increase_after_date,
      :registrants, :increase_by)

    # This is gross
    rp[:increase_by_dollars] = rp[:increase_by] unless rp[:increase_by_dollars]
    rp[:date] = rp[:increase_after_date] unless rp[:date]
    rp[:registrants] = rp[:increase_after_total_registrants] unless rp[:date]
    # This is gross
    rp.slice(*PricingTier.columns.map(&:name).map(&:to_sym))
    # Maybe think about naming the fields in ember-land the same as in rails
  end

  def create_pricing_tier_params
    attributes = update_pricing_tier_params

    event_relationship = params
      .require(:data).require(:relationships)
      .require(:event).require(:data).permit(:id)

    attributes.merge(event_id: event_relationship[:id])
  end
end<commit_msg>clean up the pricing tiers controller<commit_after>class Api::PricingTiersController < Api::EventResourceController
  private

  # The fields are named different on teh server than the client
  def update_pricing_tier_params
    whitelistable_params do |whitelister|
      whitelister.permit(
        :date,
        :registrants, :increase_by_dollars)
    end
  end

  def create_pricing_tier_params
    whitelistable_params do |whitelister|
      whitelister.permit(
        :event_id,
        :date,
        :registrants, :increase_by_dollars)
    end
  end
end
{'fraction_non_alphanumeric': 0.08151549942594719, 'fraction_numerical': 0.0, 'mean_word_length': 4.1114369501466275, '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': '2266057', 'n_tokens_mistral': 591, 'n_tokens_neox': 556, 'n_words': 119}