<commit_before>require 'ello/kinesis_consumer/base_processor'
require 'ello/mailchimp_wrapper'

module Ello
  module KinesisConsumer
    class MailchimpProcessor < BaseProcessor

      def user_was_created(record)
        mailchimp.upsert_to_users_list record['email'],
                                       record['subscription_preferences'],
                                       record['followed_categories']
      end

      def user_changed_email(record)
        mailchimp.remove_from_users_list record['previous_email']
        mailchimp.upsert_to_users_list record['email'], record['subscription_preferences']
      end

      def user_changed_subscription_preferences(record)
        mailchimp.upsert_to_users_list record['email'], record['subscription_preferences']
      end

      def user_was_deleted(record)
        mailchimp.remove_from_users_list record['email']
      end

      private<commit_msg>Add default value for when `followed_categories` is nil<commit_after>require 'ello/kinesis_consumer/base_processor'
require 'ello/mailchimp_wrapper'

module Ello
  module KinesisConsumer
    class MailchimpProcessor < BaseProcessor

      def user_was_created(record)
        mailchimp.upsert_to_users_list record['email'],
                                       record['subscription_preferences'],
                                       record['followed_categories'] || []
      end

      def user_changed_email(record)
        mailchimp.remove_from_users_list record['previous_email']
        mailchimp.upsert_to_users_list record['email'], record['subscription_preferences']
      end

      def user_changed_subscription_preferences(record)
        mailchimp.upsert_to_users_list record['email'], record['subscription_preferences']
      end

      def user_was_deleted(record)
        mailchimp.remove_from_users_list record['email']
      end

      private
{'fraction_non_alphanumeric': 0.07127659574468086, 'fraction_numerical': 0.0, 'mean_word_length': 3.002127659574468, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2972866', 'n_tokens_mistral': 513, 'n_tokens_neox': 506, 'n_words': 82}