diff --git a/app/assets/stylesheets/light/home.css b/app/assets/stylesheets/light/home.css index afad32d..f04adf5 100644 --- a/app/assets/stylesheets/light/home.css +++ b/app/assets/stylesheets/light/home.css @@ -2,3 +2,25 @@ Place all the styles related to the matching controller here. They will automatically be included in application.css. */ + +.badge-users-count { + margin-top: 10px; +} + +.btn-mail { + margin-top: 5px; +} + +#users_per_page { + width: 50px; + height: 30px; +} + +#searchbox { + height: 30px; +} + +.brand { + font-weight: bold !important; + margin-top: 5px !important; +} diff --git a/app/models/light/user.rb b/app/models/light/user.rb index f341f46..8309e65 100644 --- a/app/models/light/user.rb +++ b/app/models/light/user.rb @@ -39,8 +39,8 @@ class User end end - scope :subscribed_users, -> { where is_subscribed: true } - scope :unsubscribed_users, -> { where is_subscribed: false } + scope :subscribed_users, -> { where(is_subscribed: true, sidekiq_status: 'Subscribed') } + scope :unsubscribed_users, -> { where(is_subscribed: false, sidekiq_status: 'Unsubscribed') } scope :new_users, -> { where(is_subscribed: false, sidekiq_status: NEW_USER) } scope :blocked_users, -> { where(is_subscribed: false, sidekiq_status: 'Block') } scope :bounced_users, -> { where(is_subscribed: false, sidekiq_status: 'Bounced') } diff --git a/app/views/light/newsletters/_top_navbar.html.haml b/app/views/light/newsletters/_top_navbar.html.haml index a1aff22..bbabe36 100644 --- a/app/views/light/newsletters/_top_navbar.html.haml +++ b/app/views/light/newsletters/_top_navbar.html.haml @@ -1,4 +1,4 @@ -= nav_bar :brand => "Newsletters", :responsive => true, :static => :top, :fluid => :true do += nav_bar :brand => 'Newsletters', :responsive => true, :static => :top, :fluid => :true do = menu_group do = menu_item "Add Newsletter", new_newsletter_path = menu_item "Opt in letters", opt_in_newsletters_path @@ -10,6 +10,7 @@ = menu_item "Show Users", users_path, ({:method => 'get'} if params[:controller] == 'light/users' && params[:action].in?(['new', 'create'])) = menu_group :pull => :right do - = content_tag :a, "Send Mail", :href => sendmailer_path, :class => 'btn btn-danger', :data => { :confirm => 'Are you sure ?'} - = content_tag :a, "Test Mail", :href => testmail_path, :class => "btn btn-success" + .btn-mail + = content_tag :a, "Send Mail", :href => sendmailer_path, :class => 'btn btn-danger', :data => { :confirm => 'Are you sure ?'} + = content_tag :a, "Test Mail", :href => testmail_path, :class => 'btn btn-success' %br diff --git a/app/views/light/users/index.html.haml b/app/views/light/users/index.html.haml index fa847c2..8df5ac2 100644 --- a/app/views/light/users/index.html.haml +++ b/app/views/light/users/index.html.haml @@ -24,10 +24,10 @@ %option{:value => 'Opt in mail sent'} Opt in Mail Sent: #{Light::User.opt_in_users.count} %ul.nav.navbar-nav.pull-right - %li - %h5= raw ("Subscribers: #{badge(Light::User.subscribed_users.count)}") + %li.badge-users-count + %h5= raw ("Subscribed users: #{badge(Light::User.subscribed_users.count)}") - %li + %li.badge-users-count %h5= raw ("New users: #{badge(Light::User.new_users.count)}") .row @@ -55,13 +55,13 @@ %a{ :href => "/newsletter/users/{{_id.$oid}}", data:{ :confirm => 'Are you sure?', method: 'delete'}, :class => 'btn btn-sm btn-danger' } Delete - .col-lg-12.padding_none.text-center + .col-lg-12.padding_none.pull-right #user_pagination.col-lg-12 .col-lg-6.content :javascript var users_data = #{@users.to_json} var total_count = #{@users.count} - $('#searchbox').css('height',30) - $('.per-page').css('width',90) initialize_filterjs_table('#users tbody', users_data, '#user-template', '', [], '#user_pagination', '#users_per_page') + $('.per-page').css('width',90) + $('.per-page').css('height',30) \ No newline at end of file diff --git a/lib/tasks/update_user_status.rake b/lib/tasks/update_user_status.rake new file mode 100644 index 0000000..81bf857 --- /dev/null +++ b/lib/tasks/update_user_status.rake @@ -0,0 +1,57 @@ +namespace :light do + desc 'Checking and updating the User status (Subscribed and Unsubscribed)' + task :update_user_status => :environment do + + # setting status to Unsubscribed for users whose flag 'is_subscribed' is false + # and status is nil + puts "\n\n Unsubscribed Update Status : " + puts Light::User.where(is_subscribed: false, sidekiq_status: nil, is_blocked: false) + .update_all(sidekiq_status: 'Unsubscribed') + puts Light::User.where(is_subscribed: false, sidekiq_status: nil, is_blocked: true) + .update_all(sidekiq_status: 'Unsubscribed') + + # setting status to Subscribed for users whose flag 'is_subscribed' is true + # and status is nil + puts "\n\n Subscribed Update Status : " + puts Light::User.where(is_subscribed: true, sidekiq_status: nil) + .update_all(sidekiq_status: 'Subscribed') + + # change 'web subscription request' status to 'Unsubscribed' + # 1. add previous status into source field + puts "\n\n Change 'web subscription request' status to 'Unsubscribed' : " + web_subscription = Light::User.where(sidekiq_status: 'web subscription request') + puts web_subscription.update_all(source: 'web subscription request') + + # 2. change status to 'Unsubscribed' + puts web_subscription.update_all(sidekiq_status: 'Unsubscribed') + + + # Fix flag 'is_subscribed' and 'is_blocked' for Blocked Users + puts "\n\n Fix flag is_subscribed : " + puts Light::User.where(sidekiq_status: 'Block') + .update_all(is_subscribed: false, is_blocked: true) + + puts Light::User.where(is_subscribed: true, is_blocked: true) + .update_all(is_subscribed: false, sidekiq_status: 'Block') + + puts "\n\n Fix flag is_blocked :" + puts Light::User.where(is_blocked: nil) + .update_all(is_blocked: false) + + def check_status(status) + Light::User.where(sidekiq_status: status).count + end + + # Status wise count of User + puts "\n\n Total no of User Status : " + + "\n Subscribed : #{check_status('Subscribed')}" + + "\n Unsubscribed : #{check_status('Unsubscribed')}" + + "\n New User : #{check_status('new user')}" + + "\n Invalid : #{check_status('Invalid')}" + + "\n Spam : #{check_status('Spam')}" + + "\n Blocked : #{check_status('Block')}" + + "\n Bounced : #{check_status('Bounced')}" + + "\n Opt in User: #{check_status('Opt in mail sent')}" + end +end +