ish_models 0.0.33.229 → 0.0.33.231

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: f7a90237b3ffeec198b9d6732898d879fbc4b1958f66caa722bdb4902222f408
4
+ data.tar.gz: 72ee5abe32d9966fb5a82d5bfc3c147a0ca20e5892a8c412eee838c1e8aefaf1
5
5
  SHA512:
6
- metadata.gz: d8441aa5354f28cbeaf28273b1a896066d7416e46258bbf5245d041f4a53ae6fe6f2613456a80c4e4568f49c9a6df3feeb7c29090bca50c5e12138ee41b389fe
7
- data.tar.gz: be17d74a00957011492cdf197f17c2666bb187bcdbf9bd55c2d0d18db83846e743c5071c2d1afadd176a4e85472caad6917daa553b38ee083aadce65bf38dfb5
6
+ metadata.gz: 6ecc759ec798a3e34e7d422b601059012cf9291418fe049925fb86c9bd23cf2e1362f4278853173361608aacc54f201c41270ae4516988e81f0791de35a7b140
7
+ data.tar.gz: f0b6519444a7eca6208dd5d31bdb266737a3223a7f57ba3643318d3285e02b074bd1334c08e076469df03f13c821ae9b40c1885602be51819650c15a79422b71
@@ -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/photo.rb CHANGED
@@ -15,7 +15,6 @@ class Photo
15
15
  belongs_to :user_profile, :class_name => 'Ish::UserProfile', :inverse_of => :profile_photo, :optional => true
16
16
 
17
17
  belongs_to :report, :optional => true
18
- belongs_to :feature, :optional => true
19
18
  belongs_to :gallery, :optional => true
20
19
  belongs_to :newsitem, :optional => true
21
20
 
@@ -36,7 +35,7 @@ class Photo
36
35
 
37
36
  field :is_public, :type => Boolean, :default => true
38
37
  field :is_trash, :type => Boolean, :default => false # @TODO: nuke this boolean _vp_ 20170515
39
- default_scope ->{ where({ :is_trash => false }) } # @TODO: nuke default scopes
38
+ default_scope ->{ where({ :is_trash => false }) }
40
39
 
41
40
  has_mongoid_attached_file :photo,
42
41
  :styles => {
data/lib/report.rb CHANGED
@@ -6,7 +6,6 @@ class Report
6
6
 
7
7
  field :name, :type => String
8
8
  validates :name, :presence => true
9
- # index({ :name => 1 }, { :unique => true })
10
9
  index({ :name => 1, :is_trash => 1 })
11
10
 
12
11
  field :slug
@@ -14,6 +13,8 @@ class Report
14
13
  index({ :slug => 1 }, { :unique => true })
15
14
  before_validation :set_slug, :on => :create
16
15
 
16
+ field :subhead
17
+
17
18
  ## Can be one of: default (nil), longscroll,
18
19
  ## wordpress e.g. https://piousbox.com/wp-json/wp/v2/posts?slug=intro
19
20
  # ITEM_TYPES = %w| longscroll wordpress |
@@ -23,47 +24,23 @@ class Report
23
24
  field :raw_json
24
25
 
25
26
  field :is_trash, :type => Boolean, :default => false
26
- index({ :is_trash => 1, :is_public => 1 }, { name: 'default_index' })
27
+ index({ :is_trash => 1, :is_public => 1 })
27
28
 
28
29
  field :is_public, :type => Boolean, :default => true
29
30
  index({ :is_public => 1 })
30
- scope :public, ->{
31
- where({ is_public: true })
32
- }
33
-
34
- field :is_feature, :type => Boolean, :default => false
35
- index({ :is_feature => 1 })
36
-
37
- field :is_done, :type => Boolean, :default => true
38
- index({ :is_done => 1 })
31
+ scope :public, ->{ where({ is_public: true }) }
39
32
 
40
33
  field :x, :type => Float
41
34
  field :y, :type => Float
42
-
43
- field :lang, :type => String, :default => 'en'
44
- index({ :lang => 1 })
35
+ field :z, :type => Float
45
36
 
46
37
  belongs_to :user_profile, :optional => true, :class_name => 'Ish::UserProfile'
47
38
 
48
- # validates :user, :presence => true, :allow_nil => false
49
- field :username, :type => String, :default => 'anonymous'
50
- validates :username, :presence => true, :allow_nil => false
51
- index({ :username => 1 })
52
-
53
- field :issue
54
- field :subhead
55
-
56
39
  has_one :photo
57
40
 
58
- field :n_upvotes, :default => 0
59
- field :n_spamvotes, :default => 0
60
-
61
- default_scope ->{
62
- where({ is_public: true, is_trash: false }).order_by({ created_at: :desc })
63
- }
64
-
65
41
  has_many :newsitems
66
42
 
43
+ ## @TODO: trash, remove
67
44
  def self.list conditions = { :is_trash => false }
68
45
  out = self.where( conditions ).order_by( :name => :asc ).limit( 100 )
69
46
  [['', nil]] + out.map { |item| [ item.name, item.id ] }
@@ -74,10 +51,6 @@ class Report
74
51
  self::PER_PAGE
75
52
  end
76
53
 
77
- def self.all
78
- self.where( :is_public => true, :is_trash => false ).order_by( :created_at => :desc )
79
- end
80
-
81
54
  def self.clear
82
55
  if Rails.env.test?
83
56
  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.231
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox