wco_models 3.1.0.61 → 3.1.0.62

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 486108c2ea569d03ce5ae9aa5356b34fc93a95595cb22b2ef5ad1954aa4120d0
4
- data.tar.gz: 42869ee9a142532a6710a3fc33a43b26d5c37c1bc6f07f13a625d2c137992a38
3
+ metadata.gz: ef2b8e4bef23e27158ed837b1aea47e139f21d1e5465a94f850acb62d843765b
4
+ data.tar.gz: 7209dcbe82884748e25f90ec28e3e99ac002838086c492a7a6c4de025d087ca3
5
5
  SHA512:
6
- metadata.gz: 28cdd389154518d44da11512d2f0f0ccbcc2bbf9c6e44c7889bacf1f9abd15887375bf6541fb4ea85a2df7d60c3cd9ccb3cc3d677c3a41c2fe1f17c63eec1abc
7
- data.tar.gz: 91e297e8dfe0772ebbe554a93d55c2264cedcb891a68846e1cca4eb899574f7aa9390359bb8d475c493ffcf81562c4ed5a45664961694c6ad70e476535bd434c
6
+ metadata.gz: 5d26f9a04b158184b51a29af4192185657af21b0911dcb7a839396178b07b17d10ed4513a56aec82e1cfbac1ae27cee017e942ab66ee3a592ba3b846959e9ceb
7
+ data.tar.gz: 69d0d4188dc22faa92e30f95434388aeacf261ce6bfd4db23ac047b340b1c0d187cca33b3114b8ddda832c0e76d18185b08adbc61ec4102ed21367f5781e43fa
@@ -138,4 +138,6 @@ h5.title {
138
138
 
139
139
  .padded {
140
140
  margin: 0.5em;
141
+ width: 100%;
141
142
  }
143
+
@@ -54,8 +54,8 @@ class WcoEmail::Context
54
54
  belongs_to :email_template, class_name: 'WcoEmail::EmailTemplate'
55
55
  def tmpl; email_template; end
56
56
 
57
- belongs_to :scheduled_email_action, class_name: 'WcoEmail::ScheduledEmailAction', optional: true
58
- def sch; scheduled_email_action; end
57
+ belongs_to :email_action, class_name: 'WcoEmail::EmailAction', optional: true
58
+ def sch; email_action; end
59
59
 
60
60
  belongs_to :email_campaign, class_name: 'WcoEmail::EmailCampaign', optional: true
61
61
 
@@ -66,17 +66,14 @@ class WcoEmail::Context
66
66
  field :unsubscribed_at, type: DateTime
67
67
 
68
68
 
69
- def notsent
70
- WcoEmail::EmailContext.where( sent_at: nil, unsubscribed_at: nil )
69
+ def self.notsent
70
+ where( sent_at: nil, unsubscribed_at: nil )
71
71
  end
72
- def self.notsent; new.notsent; end
73
72
 
74
73
 
75
- def scheduled
76
- # or({ :send_at.lte => Time.now }, { :send_at => nil }) ## This won't work b/c I need draft state!
77
- WcoEmail::EmailContext.where({ :send_at.lte => Time.now })
74
+ def self.scheduled
75
+ where( :send_at.lte => Time.now )
78
76
  end
79
- def self.scheduled; new.scheduled; end
80
77
 
81
78
 
82
79
  belongs_to :lead, class_name: 'Wco::Lead'
@@ -16,7 +16,7 @@ class WcoEmail::EmailAction
16
16
  STATUS_INACTIVE = 'inactive'
17
17
  STATUS_TRASH = 'trash'
18
18
  STATUS_UNSUBSCRIBED = 'unsubscribed'
19
- STATUSS = [ STATUS_ACTIVE, STATUS_INACTIVE, STATUS_UNSUBSCRIBED, STATUS_TRASH ]
19
+ STATUSES = [ nil, STATUS_ACTIVE, STATUS_INACTIVE, STATUS_UNSUBSCRIBED, STATUS_TRASH ]
20
20
  field :status, type: :string
21
21
  scope :active, ->{ where( status: STATUS_ACTIVE ) }
22
22
 
@@ -25,7 +25,6 @@ class WcoEmail::EmailAction
25
25
  belongs_to :email_action_template, class_name: 'WcoEmail::EmailActionTemplate'
26
26
  validates :email_action_template, uniqueness: { scope: :lead }
27
27
  def tmpl; email_action_template; end
28
- def tmpl= k; email_action_template = k; end
29
28
 
30
29
  has_many :email_contexts, class_name: 'WcoEmail::Context'
31
30
  def ctxs; email_contexts; end
@@ -38,20 +37,20 @@ class WcoEmail::EmailAction
38
37
  sch.update({ status: STATUS_INACTIVE })
39
38
 
40
39
  # send now
41
- ctx = Ctx.create!({
42
- email_template_id: sch.act.tmpl.id,
43
- from_email: sch.act.tmpl.from_email,
44
- lead_id: sch.lead.id,
45
- scheduled_email_action_id: sch.act.id,
46
- send_at: Time.now,
47
- subject: sch.act.tmpl.subject,
40
+ ctx = WcoEmail::Context.create!({
41
+ email_action: sch,
42
+ email_template: sch.tmpl.email_template,
43
+ from_email: sch.tmpl.email_template.from_email,
44
+ lead: sch.lead,
45
+ send_at: Time.now,
46
+ subject: sch.tmpl.email_template.subject,
48
47
  })
49
48
 
50
49
  # schedule next actions & update the action
51
- sch.act.ties.each do |tie|
52
- next_sch = Sch.find_or_initialize_by({
53
- lead_id: sch.lead_id,
54
- email_action_id: tie.next_email_action.id,
50
+ sch.tmpl.ties.each do |tie|
51
+ next_sch = self.class.find_or_initialize_by({
52
+ lead_id: sch.lead_id,
53
+ email_action_template_id: tie.next_tmpl.id,
55
54
  })
56
55
  next_sch.perform_at = eval(tie.next_at_exe)
57
56
  next_sch.status = STATUS_ACTIVE
@@ -59,10 +58,9 @@ class WcoEmail::EmailAction
59
58
  end
60
59
  end
61
60
 
61
+
62
62
  def self.list
63
63
  [[nil,nil]] + all.map { |p| [ "#{p.lead&.email} :: #{p.tmpl&.slug}", p.id ] }
64
64
  end
65
-
66
-
67
65
  end
68
66
 
@@ -13,23 +13,23 @@ class WcoEmail::EmailActionTemplate
13
13
  validates :slug, uniqueness: true, allow_nil: true
14
14
  index({ slug: 1 }, { unique: true, name: "slug_idx" })
15
15
 
16
- belongs_to :email_template, class_name: 'WcoEmail::EmailTemplate'
17
- def tmpl; email_template; end
16
+ # field :from_email ## this is in email_template
18
17
 
19
- has_many :scheduled_email_actions, class_name: 'WcoEmail::ScheduledEmailAction'
20
- def schs; scheduled_email_actions; end
18
+ belongs_to :email_template, class_name: 'EmailTemplate'
21
19
 
22
- has_many :ties, class_name: 'WcoEmail::EmailActionTie', inverse_of: :email_action
23
- has_many :prev_ties, class_name: 'WcoEmail::EmailActionTie', inverse_of: :next_email_action
20
+ has_many :email_actions, class_name: 'EmailAction'
21
+
22
+ has_many :ties, class_name: '::WcoEmail::EmailActionTemplateTie', inverse_of: :tmpl
23
+ has_many :prev_ties, class_name: '::WcoEmail::EmailActionTemplateTie', inverse_of: :next_tmpl
24
24
  accepts_nested_attributes_for :ties
25
25
 
26
- has_many :email_filters, class_name: 'WcoEmail::EmailFilter', inverse_of: :email_action
26
+ has_many :email_filters, class_name: 'EmailFilter', inverse_of: :email_action
27
27
 
28
- ## @TODO: change this right now.
29
- field :deleted_at, default: nil, type: :time
28
+ def to_s
29
+ slug
30
+ end
30
31
 
31
32
  def self.list
32
33
  [[nil,nil]] + all.map { |a| [ a.slug, a.id ] }
33
34
  end
34
-
35
35
  end
@@ -0,0 +1,15 @@
1
+
2
+ class WcoEmail::EmailActionTemplateTie
3
+ include Mongoid::Document
4
+ include Mongoid::Timestamps
5
+ store_in collection: 'office_email_action_template_tie'
6
+
7
+ attr_accessor :to_delete
8
+
9
+ belongs_to :tmpl, class_name: 'EmailActionTemplate', inverse_of: :ties
10
+ belongs_to :next_tmpl, class_name: 'EmailActionTemplate', inverse_of: :prev_ties
11
+
12
+ field :next_at_exe, type: :string
13
+ validates :next_at_exe, presence: true
14
+
15
+ end
@@ -89,6 +89,7 @@ class WcoEmail::EmailTemplate
89
89
  'Wasya Co Mailer <wasyacomailer@gmail.com>',
90
90
  ];
91
91
  FROM_EMAILS_2 = [
92
+ [ nil, nil ],
92
93
 
93
94
  [ 'Victor Pudeyev <piousbox@gmail.com>', 'piousbox@gmail.com' ],
94
95
  [ 'Victor Pudeyev <victor@piousbox.com>', 'victor@piousbox.com' ],
@@ -115,7 +116,7 @@ class WcoEmail::EmailTemplate
115
116
 
116
117
  ## 2023-03-04 _vp_ This works!
117
118
  def get_binding
118
- @lead = Lead.where( email: 'stub@wasya.co' ).first
119
+ # @lead = Lead.where( email: 'stub@wasya.co' ).first
119
120
  binding()
120
121
  end
121
122
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.61
4
+ version: 3.1.0.62
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-12 00:00:00.000000000 Z
11
+ date: 2024-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -413,6 +413,7 @@ files:
413
413
  - app/models/wco_email/conversation.rb
414
414
  - app/models/wco_email/email_action.rb
415
415
  - app/models/wco_email/email_action_template.rb
416
+ - app/models/wco_email/email_action_template_tie.rb
416
417
  - app/models/wco_email/email_filter.rb
417
418
  - app/models/wco_email/email_template.rb
418
419
  - app/models/wco_email/message.rb