<commit_before>require "#{Rails.root}/app/helpers/promos_helper"
namespace :promo do
  # Generates the promo tokens and sends emails
  task :launch_promo => :environment do
    include PromosHelper
    begin
      unless promo_running?
        puts "Promo is not running, check the active_promo_id config var."
      end

      publishers = Publisher.where(promo_token_2018q1: nil).where(promo_enabled_2018q1: false)

      publishers.find_each do |publisher|
        token = PublisherPromoTokenGenerator.new(publisher: publisher).perform
        next unless token
        PromoMailer.activate_promo_2018q1(publisher).deliver_later
      end

    rescue PublisherPromoTokenGenerator::InvalidPromoIdError => error
      require "raven"
      Raven.capture_exception(error)
      puts "Did not launch promo because of invalid promo id. Check the active_promo_id config var."
    end
  end
end<commit_msg>only send 'activate promo email' in lauch_promo task to publishers that have a valid email address<commit_after>require "#{Rails.root}/app/helpers/promos_helper"
namespace :promo do
  # Generates the promo tokens and sends emails
  task :launch_promo => :environment do
    include PromosHelper
    begin
      unless promo_running?
        puts "Promo is not running, check the active_promo_id config var."
      end

      publishers = Publisher.where(promo_token_2018q1: nil).where(promo_enabled_2018q1: false).where.not(email: nil)

      publishers.find_each do |publisher|
        token = PublisherPromoTokenGenerator.new(publisher: publisher).perform
        next unless token
        PromoMailer.activate_promo_2018q1(publisher).deliver_later
      end

    rescue PublisherPromoTokenGenerator::InvalidPromoIdError => error
      require "raven"
      Raven.capture_exception(error)
      puts "Did not launch promo because of invalid promo id. Check the active_promo_id config var."
    end
  end
end
{'fraction_non_alphanumeric': 0.06436420722135008, 'fraction_numerical': 0.015698587127158554, 'mean_word_length': 3.67481662591687, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5600868', 'n_tokens_mistral': 586, 'n_tokens_neox': 564, 'n_words': 157}