46 lines
1.0 KiB
Ruby
46 lines
1.0 KiB
Ruby
module JamRuby
|
|
class EmailBatchSet < ActiveRecord::Base
|
|
self.table_name = "email_batch_sets"
|
|
|
|
belongs_to :email_batch, :class_name => 'JamRuby::EmailBatch'
|
|
belongs_to :user, :class_name => 'JamRuby::User'
|
|
|
|
def self.load_set(batch, user_ids)
|
|
bset = self.new
|
|
bset.email_batch_id = batch.id
|
|
bset.user_ids = user_ids.join(',')
|
|
bset.started_at = Time.now
|
|
bset.batch_count = user_ids.size
|
|
bset.save!
|
|
bset
|
|
end
|
|
|
|
def self.progress_set(batch, user, trigger_idx)
|
|
bset = self.new
|
|
bset.email_batch = batch
|
|
bset.user = user
|
|
bset.started_at = Time.now
|
|
bset.batch_count = 1
|
|
bset.trigger_index = trigger_idx
|
|
bset.sub_type = batch.sub_type
|
|
bset.save!
|
|
bset
|
|
end
|
|
|
|
def subject
|
|
unless sub_type.blank?
|
|
return EmailBatchProgression.subject(self.sub_type)
|
|
end
|
|
''
|
|
end
|
|
|
|
def title
|
|
unless sub_type.blank?
|
|
return EmailBatchProgression.title(self.sub_type)
|
|
end
|
|
''
|
|
end
|
|
|
|
end
|
|
end
|