VRFS-1483 integrating admin interface
This commit is contained in:
parent
22104e3a97
commit
eecdbebf3d
|
|
@ -23,18 +23,46 @@ ActiveAdmin.register JamRuby::EmailBatch, :as => 'Batch Emails' do
|
|||
default_actions
|
||||
end
|
||||
|
||||
# show do
|
||||
# attributes_table do
|
||||
# row 'Who?' do |obj| obj.text_short end
|
||||
# row 'Quote' do |obj| obj.text_long end
|
||||
# row :image do |obj|
|
||||
# image_tag(obj.image_url, :size => '50x50')
|
||||
# end
|
||||
# row 'State' do |obj| obj.aasm_state end
|
||||
# row 'Position' do |obj| obj.position end
|
||||
# row 'Updated' do |obj| obj.updated_at end
|
||||
# end
|
||||
# end
|
||||
action_item :only => :show do
|
||||
link_to("Run Test Batch (#{resource.test_count})",
|
||||
"/admin/batch_emails/#{resource.id}/batch_test",
|
||||
:confirm => "Run test batch with #{resource.test_count} emails?")
|
||||
end
|
||||
|
||||
action_item :only => :show do
|
||||
link_to("Run Live Batch (#{User.email_opt_in.count})",
|
||||
"/admin/batch_emails/#{resource.id}/batch_send",
|
||||
:confirm => "Run LIVE batch with #{User.email_opt_in.count} emails?")
|
||||
end
|
||||
|
||||
show :title => 'Batch Email' do |obj|
|
||||
panel 'Email Contents' do
|
||||
attributes_table_for obj do
|
||||
row 'Subject' do |obj| obj.subject end
|
||||
row 'From' do |obj| obj.from_email end
|
||||
row 'Test Emails' do |obj| obj.test_emails end
|
||||
row 'Body' do |obj| obj.body end
|
||||
row 'State' do |obj| obj.aasm_state end
|
||||
end
|
||||
end
|
||||
columns do
|
||||
column do
|
||||
panel 'Sending Parameters' do
|
||||
attributes_table_for obj do
|
||||
row 'Opt-in User Count' do |obj| User.email_opt_in.count end
|
||||
row 'Sent Count' do |obj| obj.sent_count end
|
||||
row 'Started At' do |obj| obj.started_at end
|
||||
row 'Completed At' do |obj| obj.completed_at end
|
||||
row 'Updated' do |obj| obj.updated_at end
|
||||
end
|
||||
end
|
||||
end
|
||||
column do
|
||||
panel 'Send Results' do
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
controller do
|
||||
|
||||
|
|
@ -50,4 +78,16 @@ ActiveAdmin.register JamRuby::EmailBatch, :as => 'Batch Emails' do
|
|||
|
||||
end
|
||||
|
||||
member_action :batch_test, :method => :get do
|
||||
batch = EmailBatch.find(params[:id])
|
||||
batch.send_test_batch
|
||||
redirect_to admin_batch_email_path(batch.id)
|
||||
end
|
||||
|
||||
member_action :batch_send, :method => :get do
|
||||
batch = EmailBatch.find(params[:id])
|
||||
batch.deliver_batch
|
||||
redirect_to admin_batch_email_path(batch.id)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
<tr>
|
||||
<td align="left"><h1 style="font-size:22px;font-weight:normal;margin-top:0px"><font color="#F34E1C" face="Arial, Helvetica, sans-serif"><%= yield(:title) %></font></h1>
|
||||
<p><font size="3" color="#AAAAAA" face="Arial, Helvetica, sans-serif"><%= @body %></font></p>
|
||||
<p><font size="3" color="#AAAAAA" face="Arial, Helvetica, sans-serif"><%= @body.html_safe %></font></p>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -44,11 +44,6 @@ module JamRuby
|
|||
|
||||
# has_many :email_batch_results, :class_name => 'JamRuby::EmailBatchResult'
|
||||
|
||||
def self.qualified_users
|
||||
User.select(:email)
|
||||
.where(:opt_out_email_batch => false)
|
||||
end
|
||||
|
||||
def self.create_with_params(params)
|
||||
obj = self.new
|
||||
obj.update_with_params(params)
|
||||
|
|
@ -64,9 +59,9 @@ module JamRuby
|
|||
self
|
||||
end
|
||||
|
||||
def deliver
|
||||
def deliver_batch
|
||||
self.perform_event('do_batch_run!')
|
||||
self.class.qualified_users.pluck(:id).find_in_batches(batch_size: 100) do |user_ids|
|
||||
User.email_opt_in.pluck(:id).find_in_batches(batch_size: 1000) do |user_ids|
|
||||
BatchMailer.send_batch_email(self.id, user_ids).deliver
|
||||
end
|
||||
end
|
||||
|
|
@ -130,7 +125,7 @@ module JamRuby
|
|||
end
|
||||
|
||||
def running_batch
|
||||
self.update_with_conflict_validation({:qualified_count => self.class.qualified_users.count,
|
||||
self.update_with_conflict_validation({:qualified_count => User.email_opt_in.count,
|
||||
:sent_count => 0,
|
||||
:started_at => Time.now
|
||||
})
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ module JamRuby
|
|||
scope :fans, where(:musician => false)
|
||||
scope :geocoded_users, where(['lat IS NOT NULL AND lng IS NOT NULL'])
|
||||
scope :musicians_geocoded, musicians.geocoded_users
|
||||
scope :email_opt_in, where(:opt_out_email_batch => false)
|
||||
|
||||
def user_progression_fields
|
||||
@user_progression_fields ||= Set.new ["first_downloaded_client_at", "first_ran_client_at", "first_music_session_at", "first_real_music_session_at", "first_good_music_session_at", "first_certified_gear_at", "first_invited_at", "first_friended_at", "first_recording_at", "first_social_promoted_at" ]
|
||||
|
|
|
|||
Loading…
Reference in New Issue