<commit_before># frozen_string_literal: true
class MemberUpdater
  def self.run(member, params)
    new(member, params).run
  end

  def initialize(member, params)
    @member = member
    @params = params
  end

  def run
    @member.name = @params[:name] if @params.key? :name
    @member.actionkit_user_id = action_kit_user_id if action_kit_user_id.present?
    @member.assign_attributes(filtered_params)
    @member.save!
  end

  private

  def action_kit_user_id
    AkidParser.parse(@params[:akid], Settings.action_kit.akid_secret)[:actionkit_user_id]
  end

  def filtered_params
    hash = @params.try(:to_unsafe_hash) || @params.to_h # for ActionController::Params
    hash.symbolize_keys.compact.keep_if { |k| permitted_keys.include? k }
  end

  def permitted_keys
    Member.new.attributes.keys.map(&:to_sym).reject! { |k| k == :id }
  end
end<commit_msg>Removing ! from save on MemberUpdater to keep ActionBuilder from breaking<commit_after># frozen_string_literal: true
class MemberUpdater
  def self.run(member, params)
    new(member, params).run
  end

  def initialize(member, params)
    @member = member
    @params = params
  end

  def run
    @member.name = @params[:name] if @params.key? :name
    @member.actionkit_user_id = action_kit_user_id if action_kit_user_id.present?
    @member.assign_attributes(filtered_params)
    @member.save
  end

  private

  def action_kit_user_id
    AkidParser.parse(@params[:akid], Settings.action_kit.akid_secret)[:actionkit_user_id]
  end

  def filtered_params
    hash = @params.try(:to_unsafe_hash) || @params.to_h # for ActionController::Params
    hash.symbolize_keys.compact.keep_if { |k| permitted_keys.include? k }
  end

  def permitted_keys
    Member.new.attributes.keys.map(&:to_sym).reject! { |k| k == :id }
  end
end
{'fraction_non_alphanumeric': 0.10584958217270195, 'fraction_numerical': 0.0, 'mean_word_length': 4.175792507204611, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2860724', 'n_tokens_mistral': 622, 'n_tokens_neox': 606, 'n_words': 126}