<commit_before>module FightForTheFuture
    def FightForTheFuture.help
      puts '# Methods'
      
      [
        'find_or_create_action_page_by_tag',
        'refresh_email_statistics',
      ]
    end

    def FightForTheFuture.find_or_create_action_page_by_tag(tag)
        unless page = ActionPage.find_by_name(tag)
          campaign = Campaign.find_by_name('CMS')
          
          page = ActionPage.create(
            name: tag,
            movement_id: 1,
            type: 'ActionPage',
            action_sequence_id: campaign.action_sequences.first.id
          )

          petition = PetitionModule.create!(
            :title => "Sign, please",
            :content => 'We the undersigned...',
            :petition_statement => "This is the petition statement",
            :signatures_goal => 1,
            :thermometer_threshold => 0,
            :language => Language.find_by_iso_code(:en)
          )
          ContentModuleLink.create!(:page => page, :content_module => petition, :position => 3, :layout_container => :main_content)
        end

        page
    end

    def FightForTheFuture.refresh_email_statistics
      now = Time.zone.now
      UniqueActivityByEmail.delay(:run_at=>now).update!
    end

    def FightForTheFuture.delete_user_by_email(email)
      user = User.find_by_email(email)

      # Delete user.
      ActiveRecord::Base.connection.execute "DELETE FROM `users` WHERE (email = '#{email}') LIMIT 1"

      # Delete events.
      UserActivityEvent.where(user_id: user.id).each do
        |e|
        e.delete
      end
    end
end
<commit_msg>Find or create user method<commit_after>module FightForTheFuture
    def FightForTheFuture.help
      puts '# Methods'
      
      [
        'find_or_create_action_page_by_tag',
        'refresh_email_statistics',
      ]
    end

    def FightForTheFuture.find_or_create_action_page_by_tag(tag)
        unless page = ActionPage.find_by_name(tag)
          campaign = Campaign.find_by_name('CMS')
          
          page = ActionPage.create(
            name: tag,
            movement_id: 1,
            type: 'ActionPage',
            action_sequence_id: campaign.action_sequences.first.id
          )

          petition = PetitionModule.create!(
            :title => "Sign, please",
            :content => 'We the undersigned...',
            :petition_statement => "This is the petition statement",
            :signatures_goal => 1,
            :thermometer_threshold => 0,
            :language => Language.find_by_iso_code(:en)
          )
          ContentModuleLink.create!(:page => page, :content_module => petition, :position => 3, :layout_container => :main_content)
        end

        page
    end

    def FightForTheFuture.refresh_email_statistics
      now = Time.zone.now
      UniqueActivityByEmail.delay(:run_at=>now).update!
    end

    def FightForTheFuture.delete_user_by_email(email)
      user = User.find_by_email(email)

      # Delete user.
      ActiveRecord::Base.connection.execute "DELETE FROM `users` WHERE (email = '#{email}') LIMIT 1"

      # Delete events.
      UserActivityEvent.where(user_id: user.id).each do
        |e|
        e.delete
      end
    end

    def FightForTheFuture.find_or_create_member(email, first_name = '', source = '')
      # Find.
      member = User.find_by_email(email)

      # Create.
      if !member
        member = User.where(email: email, first_name: first_name, created_at: Time.now, updated_at: Time.now, created_by: "Developer", movement_id: 1, language_id: 1, source: source).build
        member.save
      end

      member
    end
end

{'fraction_non_alphanumeric': 0.09748688207677438, 'fraction_numerical': 0.0033140016570008283, 'mean_word_length': 2.2397137745974955, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5001216', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1049, 'n_words': 213}