ish_models 0.0.33.228 → 0.0.33.230

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: 72c17273c98a213fb3173169bf9cf80ac5679d575cf1c0eba0b52862a5a2bf60
4
- data.tar.gz: ab4da31fe3114aba80c648b51cf58eef1a9e2f6a78649d37f99f944806596196
3
+ metadata.gz: 9b6e8cdb5d6318f3571949e0b6bd148bf3bfba895c0f7c53f2744caf060876e0
4
+ data.tar.gz: 4c8ff28513a7c4deb978a39ac728729b6b5a10a43ea2e7e13553905655bdf423
5
5
  SHA512:
6
- metadata.gz: b7070edc5d664690a478d7c767e742b8881b49c5670474dd5314a6cf85b44b46a2b04132bcc7e0a4de6d036c1168a62e40aecaf7c5d26d091134daf622c5b7b5
7
- data.tar.gz: a9eb167806f67e420a6638a1d951a851dc10b22f4975b450bc7b42c015981e2c0d160f9dc47f7830d85e35f088a6d4bb5acd573610e807a59b2c7cd2eee3dadb
6
+ metadata.gz: 2f6c720885cd4e0b322ee54862fefba63a9d7af7e993c455dd942ec0b1f8aabfcbd9599362e5887bb0e325fd18cfad0c47f193ee7db8f31f7a5f1dae98ba6afd
7
+ data.tar.gz: 3e906a2d06e5b4ba91f7cf194cec788c8161d36930bab21fc516a6a47a100e142011ab6609f2fefbd1d17ffdfaa388845793e28ebee3b88e67af8131dd096e1b
@@ -1,6 +1,8 @@
1
1
 
2
+ ##
3
+ ## for alerting
4
+ ##
2
5
  class Iro::OptionWatch
3
-
4
6
  include Mongoid::Document
5
7
  include Mongoid::Timestamps
6
8
  store_in collection: 'iro_option_watches'
@@ -49,14 +49,18 @@ class ::Ish::EmailContext
49
49
  field :send_at, type: DateTime
50
50
 
51
51
 
52
- def self.unsent; new.unsent; end
53
- def unsent; Ish::EmailContext.where( sent_at: nil ); end
52
+ def notsent
53
+ Ish::EmailContext.where( sent_at: nil )
54
+ end
55
+ def self.notsent; new.notsent; end
56
+
54
57
 
55
- def self.scheduled; new.scheduled; end
56
58
  def scheduled
57
59
  # or({ :send_at.lte => Time.now }, { :send_at => nil }) ## This won't work b/c I need draft state!
58
60
  Ish::EmailContext.where({ :send_at.lte => Time.now })
59
61
  end
62
+ def self.scheduled; new.scheduled; end
63
+
60
64
 
61
65
  def self.from_email_list
62
66
  Ish::EmailCampaign.from_email_list
@@ -28,6 +28,33 @@ class Office::ScheduledEmailAction
28
28
 
29
29
  field :perform_at, type: :time
30
30
 
31
+ def send_and_roll
32
+ sch = self
33
+ sch.update_attributes({ state: Sch::STATE_INACTIVE })
34
+
35
+ # send now
36
+ ctx = Ctx.create!({
37
+ email_template_id: sch.act.tmpl.id,
38
+ lead_id: sch.lead.id,
39
+ send_at: Time.now,
40
+ subject: sch.act.tmpl.subject,
41
+ from_email: sch.act.tmpl.from_email,
42
+ scheduled_email_action_id: sch.act.id,
43
+ })
44
+
45
+ # schedule next actions & update the action
46
+ sch.act.ties.each do |tie|
47
+ next_act = tie.next_email_action
48
+ next_at = eval(tie.next_at_exe)
49
+ next_sch = Sch.find_or_initialize_by({
50
+ lead_id: sch.lead_id,
51
+ email_action_id: next_act.id,
52
+ })
53
+ next_sch.perform_at = next_at
54
+ next_sch.state = Sch::STATE_ACTIVE
55
+ next_sch.save!
56
+ end
57
+ end
31
58
 
32
59
  end
33
60
  ::Sch = Office::ScheduledEmailAction
data/lib/report.rb CHANGED
@@ -27,9 +27,7 @@ class Report
27
27
 
28
28
  field :is_public, :type => Boolean, :default => true
29
29
  index({ :is_public => 1 })
30
- scope :public, ->{
31
- where({ is_public: true })
32
- }
30
+ scope :public, ->{ where({ is_public: true }) }
33
31
 
34
32
  field :is_feature, :type => Boolean, :default => false
35
33
  index({ :is_feature => 1 })
@@ -58,10 +56,6 @@ class Report
58
56
  field :n_upvotes, :default => 0
59
57
  field :n_spamvotes, :default => 0
60
58
 
61
- default_scope ->{
62
- where({ is_public: true, is_trash: false }).order_by({ created_at: :desc })
63
- }
64
-
65
59
  has_many :newsitems
66
60
 
67
61
  def self.list conditions = { :is_trash => false }
@@ -74,10 +68,6 @@ class Report
74
68
  self::PER_PAGE
75
69
  end
76
70
 
77
- def self.all
78
- self.where( :is_public => true, :is_trash => false ).order_by( :created_at => :desc )
79
- end
80
-
81
71
  def self.clear
82
72
  if Rails.env.test?
83
73
  self.unscoped.each { |r| r.remove }
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.228
4
+ version: 0.0.33.230
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox