ish_models 0.0.33.235 → 0.0.33.236

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8002a35421fc69935dc8771ead9c2c766d4506d1d1117bd3bd9890060c3c081b
4
- data.tar.gz: 60c9c0e509691481bc9cf385549d74434d407a278fea83944f1c4f867a488ffa
3
+ metadata.gz: c580722d18c96031a011c7ea79b1a450e5b7cb721c593c4883197b177a268910
4
+ data.tar.gz: 57d131d15cc10bc3292bdb4af381de8f71b6ce6bbfa5ff526cf34563110b6dbb
5
5
  SHA512:
6
- metadata.gz: e3d523e5af0f2bef36d7fdaf20dc28d7698298be5f8a6f380011bbfb8ec5d5d625ffb4d447b75c7fb91384bda78f6580945fe0c4f307b0656176f6fe74bc0a6e
7
- data.tar.gz: 02e270850e4dfa21c2e23a6d033cc80650b9cc4bd20d6cc5f6b4e2df19a7d1c748746275cc7876c9e94068845161cd576b1980d8a9e9b37aff00c6b40b048cab
6
+ metadata.gz: 4773cc9026faf169a7a50f92e6cb82119265644e56a54a0e4d65e7d403944b391583089be21e6185e14130330f0dae41c2eb1b943dd3d7c95c6eb81e7b759252
7
+ data.tar.gz: 123104d4cd0fafb595aeb15d291f6cc38285b0db5cd50fe8669d0403cebf8162425c2ae8d7507a6f708c8daf24e2a1504cfb278e25cfd988284d7a69802da979
@@ -1,9 +1,8 @@
1
1
 
2
- #
3
- # Sends a campaign.
4
- # _vp_ 2023-02-02
5
- #
6
-
2
+ ##
3
+ ## Sends a campaign.
4
+ ## _vp_ 2023-02-02
5
+ ##
7
6
  class Ish::EmailCampaign
8
7
  include Mongoid::Document
9
8
  include Mongoid::Timestamps
@@ -14,11 +13,11 @@ class Ish::EmailCampaign
14
13
 
15
14
  PAGE_PARAM_NAME = 'email_contexts_page'
16
15
 
16
+ field :from_email
17
+ validates_presence_of :from_email
17
18
  FROM_EMAILS = %w| hello@infiniteshelter.com no-reply@infiniteshelter.com
18
19
  piousbox@gmail.com hello@piousbox.com no-reply@piousbox.com victor@piousbox.com
19
20
  admin@wasya.co hello@wasya.co no-reply@wasya.co victor@wasya.co |
20
- field :from_email
21
- validates_presence_of :from_email
22
21
  def self.from_email_list
23
22
  [ [nil, nil] ] + FROM_EMAILS.map { |i| [i, i] }
24
23
  end
@@ -40,23 +39,21 @@ class Ish::EmailCampaign
40
39
  campaign_leads&.map { |p| p.lead }
41
40
  end
42
41
 
43
-
44
- # ##
45
- # ## For templating:
46
- # ##
47
- # ## commonly: name, companyName
48
- # field :tmpl, type: Hash, default: {}
49
- # def body_templated
50
- # out = email_template.body
51
- # tmpl.each do |k, v|
52
- # out.gsub!("{#{k}}", v)
53
- # end
54
- # out
55
- # end
56
-
57
- #
58
- # For tracking
59
- #
42
+ ##
43
+ ## For tracking
44
+ ##
60
45
  attr_reader :tid
61
46
 
47
+ def do_send
48
+ leads.each do |lead|
49
+ ctx = Ctx.create!({
50
+ email_template: tmpl,
51
+ from_email: tmpl.from_email,
52
+ lead_id: lead.id,
53
+ send_at: Time.now,
54
+ subject: tmpl.subject,
55
+ })
56
+ end
57
+ end
58
+
62
59
  end
data/lib/ish_models.rb CHANGED
@@ -64,6 +64,8 @@ require 'photo'
64
64
  require 'report'
65
65
  require 'video'
66
66
 
67
+ require 'office/action'
68
+ require 'office/action_tie'
67
69
  require 'office/email_action'
68
70
  require 'office/email_action_tie'
69
71
  require 'office/email_conversation'
@@ -75,4 +77,3 @@ require 'office/scheduled_email_action'
75
77
 
76
78
 
77
79
 
78
-
@@ -0,0 +1,29 @@
1
+
2
+ class Office::Action
3
+ include Mongoid::Document
4
+ include Mongoid::Timestamps
5
+ store_in collection: 'office_actions'
6
+
7
+ field :slug, type: :string
8
+ validates :slug, uniqueness: true, allow_nil: true
9
+
10
+ field :descr, type: :string ## optional
11
+
12
+
13
+ STATE_ACTIVE = 'active'
14
+ STATE_INACTIVE = 'inactive'
15
+ STATES = [ STATE_ACTIVE, STATE_INACTIVE ]
16
+ field :state, type: :string
17
+ scope :active, ->{ where( state: STATE_ACTIVE ) }
18
+
19
+
20
+ has_many :ties, class_name: '::Office::ActionTie', inverse_of: :office_action
21
+ has_many :prev_ties, class_name: '::Office::ActionTie', inverse_of: :next_office_action
22
+ accepts_nested_attributes_for :ties
23
+
24
+ field :action_exe, type: :string
25
+
26
+ field :perform_at, type: :time
27
+
28
+ end
29
+ OAct = Office::Action
@@ -0,0 +1,16 @@
1
+
2
+ class Office::ActionTie
3
+ include Mongoid::Document
4
+ include Mongoid::Timestamps
5
+ store_in collection: 'office_action_ties'
6
+
7
+ attr_accessor :to_delete
8
+
9
+ belongs_to :office_action, class_name: '::Office::Action', inverse_of: :ties
10
+ belongs_to :next_office_action, class_name: '::Office::Action', inverse_of: :prev_ties
11
+
12
+ field :next_at_exe, type: :string
13
+ validates :next_at_exe, presence: true
14
+
15
+ end
16
+ OActie = Office::ActionTie
@@ -7,10 +7,6 @@ class Office::EmailAction
7
7
  include Mongoid::Document
8
8
  include Mongoid::Timestamps
9
9
 
10
- # field :next_at_exe, type: :string
11
- # field :next_in_days, type: :string
12
- # field :next_at_time, type: :string
13
-
14
10
  field :slug, type: :string
15
11
  validates :slug, uniqueness: true, allow_nil: true
16
12
 
@@ -19,10 +15,6 @@ class Office::EmailAction
19
15
  belongs_to :email_template, class_name: '::Ish::EmailTemplate'
20
16
  def tmpl; email_template; end
21
17
 
22
- # belongs_to :prev_email_action, class_name: '::Office::EmailAction', optional: true, inverse_of: :next_email_actions
23
- # has_many :next_email_actions, class_name: '::Office::EmailAction', inverse_of: :prev_email_action
24
- # accepts_nested_attributes_for :next_email_actions
25
-
26
18
  has_many :scheduled_email_actions, class_name: '::Office::ScheduledEmailAction'
27
19
  def schs; scheduled_email_actions; end
28
20
 
@@ -31,4 +23,4 @@ class Office::EmailAction
31
23
  accepts_nested_attributes_for :ties
32
24
 
33
25
  end
34
- Act = Office::EmailAction
26
+ EAct = Office::EmailAction
@@ -11,27 +11,8 @@ class Office::EmailActionTie
11
11
  belongs_to :email_action, class_name: '::Office::EmailAction', inverse_of: :ties
12
12
  belongs_to :next_email_action, class_name: '::Office::EmailAction', inverse_of: :prev_ties
13
13
 
14
-
15
14
  field :next_at_exe, type: :string
16
15
  validates :next_at_exe, presence: true
17
16
 
18
- # field :next_in_days, type: :string
19
- # field :next_at_time, type: :string
20
-
21
- # field :slug, type: :string
22
- # validates :slug, uniqueness: true, allow_nil: true
23
-
24
- # field :descr, type: :string ## optional, can remove
25
-
26
- # belongs_to :email_template, class_name: '::Ish::EmailTemplate'
27
- # def tmpl; email_template; end
28
-
29
- # belongs_to :prev_email_action, class_name: '::Office::EmailAction', optional: true, inverse_of: :next_email_actions
30
- # has_many :next_email_actions, class_name: '::Office::EmailAction', inverse_of: :prev_email_action
31
- # accepts_nested_attributes_for :next_email_actions
32
-
33
- # has_many :scheduled_email_actions, class_name: '::Office::ScheduledEmailAction'
34
- # def schs; scheduled_email_actions; end
35
-
36
17
  end
37
- Actie = Office::EmailActionTie
18
+ EActie = Office::EmailActionTie
@@ -17,8 +17,6 @@ class Office::EmailConversation
17
17
  Lead.find( lead_ids )
18
18
  end
19
19
 
20
-
21
-
22
20
  has_many :email_messages
23
21
  def email_messages
24
22
  Office::EmailMessage.where( email_conversation_id: self.id )
@@ -85,5 +83,4 @@ class Office::EmailConversation
85
83
  end
86
84
 
87
85
  end
88
- # EmailConversation = Office::EmailConversation
89
86
  Conv = Office::EmailConversation
@@ -15,7 +15,6 @@ class Office::EmailMessageStub
15
15
  validates_presence_of :object_key
16
16
 
17
17
  field :object_path, type: :string ## A routable s3 url ## @TODO: remove this field. _vp_ 2023-03-07
18
- # validates_presence_of :object_path ## only need object_key == message_id
19
18
 
20
19
  field :wp_term_ids, type: :array, default: []
21
20
 
@@ -6,6 +6,7 @@ class Office::ScheduledEmailAction
6
6
  include Mongoid::Document
7
7
  include Mongoid::Timestamps
8
8
  include Mongoid::Paranoia
9
+ store_in collection: 'office_scheduled_email_actions'
9
10
 
10
11
  field :lead_id, type: :integer
11
12
  def lead
@@ -19,9 +20,9 @@ class Office::ScheduledEmailAction
19
20
  scope :active, ->{ where( state: STATE_ACTIVE ) }
20
21
 
21
22
  belongs_to :email_action, class_name: '::Office::EmailAction'
22
- def act; email_action; end
23
+ validates :email_action, uniqueness: { scope: :lead_id }
24
+ def act; email_action; end
23
25
  def act= a; email_action= a; end
24
- validates :email_action, uniqueness: { scope: :lead_id }
25
26
 
26
27
  has_many :email_contexts, class_name: '::Ish::EmailContext'
27
28
  def ctxs; email_contexts; end
@@ -59,23 +60,3 @@ class Office::ScheduledEmailAction
59
60
  end
60
61
  ::Sch = Office::ScheduledEmailAction
61
62
 
62
- ## @TODO: herehere 2023-03-04 _vp_ Currently Working on this
63
- =begin
64
- ::Sch.active.where( :perform_at.lte => Time.now ) do |sch|
65
- next_a = sch.next_email_action
66
-
67
- if sch.next_actions.present?
68
- sch.next_actions.each do |next_a|
69
- next_sch_a = ::Office::ScheduledEmailAction.new({
70
- email_action: next_a
71
-
72
- next_time = Time.now + eval( sch.next_in_days )
73
- next_time.time = eval( sch.next_at_time )
74
- sch.update_attribute( :perform_at, next_time )
75
- end
76
- else
77
- sch.update_attribute( state: STATE_INACTIVE )
78
- end
79
- =end
80
-
81
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33.235
4
+ version: 0.0.33.236
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
@@ -158,6 +158,8 @@ files:
158
158
  - lib/mongoid/votable.rb
159
159
  - lib/mongoid/voter.rb
160
160
  - lib/newsitem.rb
161
+ - lib/office/action.rb
162
+ - lib/office/action_tie.rb
161
163
  - lib/office/email_action.rb
162
164
  - lib/office/email_action_tie.rb
163
165
  - lib/office/email_conversation.rb