Skip to content

Commit

Permalink
Reverted opt in change
Browse files Browse the repository at this point in the history
  • Loading branch information
Shwetakale committed Aug 31, 2018
1 parent 5833593 commit b490542
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/workers/light/enqueue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Enqueue

def perform(email)
date = Date.today.strftime("%Y%m")
news = Light::Newsletter.where(newsletter_type: Light::Newsletter::VALID_NEWSLETTER_TYPES[:OPT_IN]).
news = Light::Newsletter.where(newsletter_type: Light::Newsletter::VALID_NEWSLETTER_TYPES[:MONTHLY]).
order_by([:sent_on, :desc]).first
Light::UserMailer.welcome_message(email, news, 'test_user_dummy_id').deliver if news
end
Expand Down
16 changes: 8 additions & 8 deletions app/workers/light/user_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ class UserWorker

def perform
date = Date.today.strftime("%Y%m")
#number_of_subscribed_users = Light::User.where(is_subscribed: true, :sent_on.nin => [date]).count
number_of_subscribed_users = Light::User.users_for_opt_in_mail.count
number_of_subscribed_users = Light::User.where(is_subscribed: true, :sent_on.nin => [date], is_blocked: {"$ne" => true}).count
#number_of_subscribed_users = Light::User.users_for_opt_in_mail.count
number_of_subscribed_users_count = number_of_subscribed_users
current_batch = 0
users_in_batch = 250
#newsletter = Light::Newsletter.where(newsletter_type: Light::Newsletter::VALID_NEWSLETTER_TYPES[:MONTHLY]).
# order_by([:sent_on, :desc]).first

newsletter = Light::Newsletter.where(newsletter_type: Light::Newsletter::VALID_NEWSLETTER_TYPES[:OPT_IN]).
newsletter = Light::Newsletter.where(newsletter_type: Light::Newsletter::VALID_NEWSLETTER_TYPES[:MONTHLY]).
order_by([:sent_on, :desc]).first

#newsletter = Light::Newsletter.where(newsletter_type: Light::Newsletter::VALID_NEWSLETTER_TYPES[:OPT_IN]).
# order_by([:sent_on, :desc]).first
if newsletter
while number_of_subscribed_users > 0
#user_ids = Light::User.where(is_subscribed: true, :sent_on.nin => [date], is_blocked: [nil, false]).order_by([:email_id, :asc]).limit(users_in_batch).skip(users_in_batch*current_batch).collect { |user| user.id.to_s }
user_ids = Light::User.users_for_opt_in_mail.order_by([:email_id, :asc]).limit(users_in_batch).skip(users_in_batch*current_batch).collect { |user| user.id.to_s }
user_ids = Light::User.where(is_subscribed: true, :sent_on.nin => [date], , is_blocked: {"$ne" => true}).order_by([:email_id, :asc]).limit(users_in_batch).skip(users_in_batch*current_batch).collect { |user| user.id.to_s }
#user_ids = Light::User.users_for_opt_in_mail.order_by([:email_id, :asc]).limit(users_in_batch).skip(users_in_batch*current_batch).collect { |user| user.id.to_s }
current_batch += 1
number_of_subscribed_users -= users_in_batch
Light::HardWorker.perform_async(user_ids, newsletter.id.to_s, date)
Expand Down

0 comments on commit b490542

Please sign in to comment.