wco_models 3.1.0.61 → 3.1.0.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/wco/utils.scss +2 -0
- data/app/models/wco_email/context.rb +6 -9
- data/app/models/wco_email/email_action.rb +13 -15
- data/app/models/wco_email/email_action_template.rb +10 -10
- data/app/models/wco_email/email_action_template_tie.rb +15 -0
- data/app/models/wco_email/email_template.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef2b8e4bef23e27158ed837b1aea47e139f21d1e5465a94f850acb62d843765b
|
4
|
+
data.tar.gz: 7209dcbe82884748e25f90ec28e3e99ac002838086c492a7a6c4de025d087ca3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d26f9a04b158184b51a29af4192185657af21b0911dcb7a839396178b07b17d10ed4513a56aec82e1cfbac1ae27cee017e942ab66ee3a592ba3b846959e9ceb
|
7
|
+
data.tar.gz: 69d0d4188dc22faa92e30f95434388aeacf261ce6bfd4db23ac047b340b1c0d187cca33b3114b8ddda832c0e76d18185b08adbc61ec4102ed21367f5781e43fa
|
@@ -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 :
|
58
|
-
def sch;
|
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
|
-
|
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
|
-
|
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
|
-
|
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 =
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
send_at:
|
47
|
-
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.
|
52
|
-
next_sch =
|
53
|
-
lead_id:
|
54
|
-
|
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
|
-
|
17
|
-
def tmpl; email_template; end
|
16
|
+
# field :from_email ## this is in email_template
|
18
17
|
|
19
|
-
|
20
|
-
def schs; scheduled_email_actions; end
|
18
|
+
belongs_to :email_template, class_name: 'EmailTemplate'
|
21
19
|
|
22
|
-
has_many :
|
23
|
-
|
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: '
|
26
|
+
has_many :email_filters, class_name: 'EmailFilter', inverse_of: :email_action
|
27
27
|
|
28
|
-
|
29
|
-
|
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.
|
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-
|
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
|