ish_models 0.0.33.229 → 0.0.33.230

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: c5a2776eca852c5a7e11aa0a03e7d9032e54ff2b3d0d7f8a6b4364df63029d8f
4
- data.tar.gz: 9ad2d817b825868f4e299c99eb8c915a0436df006c43499d5ea834b0072487a4
3
+ metadata.gz: 9b6e8cdb5d6318f3571949e0b6bd148bf3bfba895c0f7c53f2744caf060876e0
4
+ data.tar.gz: 4c8ff28513a7c4deb978a39ac728729b6b5a10a43ea2e7e13553905655bdf423
5
5
  SHA512:
6
- metadata.gz: d8441aa5354f28cbeaf28273b1a896066d7416e46258bbf5245d041f4a53ae6fe6f2613456a80c4e4568f49c9a6df3feeb7c29090bca50c5e12138ee41b389fe
7
- data.tar.gz: be17d74a00957011492cdf197f17c2666bb187bcdbf9bd55c2d0d18db83846e743c5071c2d1afadd176a4e85472caad6917daa553b38ee083aadce65bf38dfb5
6
+ metadata.gz: 2f6c720885cd4e0b322ee54862fefba63a9d7af7e993c455dd942ec0b1f8aabfcbd9599362e5887bb0e325fd18cfad0c47f193ee7db8f31f7a5f1dae98ba6afd
7
+ data.tar.gz: 3e906a2d06e5b4ba91f7cf194cec788c8161d36930bab21fc516a6a47a100e142011ab6609f2fefbd1d17ffdfaa388845793e28ebee3b88e67af8131dd096e1b
@@ -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.229
4
+ version: 0.0.33.230
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox