wco_models 3.1.0.83 → 3.1.0.85

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: 136fd63ec2289135d50625c8ee250e34de0ba12757cec2a0d535264d8b3af9b4
4
- data.tar.gz: f696b308e67bd35b454f11880fbf876d378c603983ae941396605ba0ca8e5a4a
3
+ metadata.gz: e35d2da6576585f442b86b8ab7589e6338a8c621659f1cb3fbc9f83135c9803e
4
+ data.tar.gz: 2640b0995ab53af533155910cd90d607188754e87e6d58898eed2a1a3c98354e
5
5
  SHA512:
6
- metadata.gz: 125155b3a50dc0c7ae25c9dcb0f642ef3127bf13a3fa11040c91240deab4ef7bfd787d0ec73065b6c31f25a111c524637822d45bc0c6739ab8676833e826cd9d
7
- data.tar.gz: e8c8f58699d02a209e9be4bfa177a987e40d67daa22db0535ade103f55dc4874ef8fb45c412ab1da49b5723996b4c734ce5cec1f48172bb6a41a22b5b73c2bae
6
+ metadata.gz: 0f55ff4f412e168ba9a2e715afd3e90abd8e44f5d209f544beec59e0d1e9125be0fe1e25763b62e14b131e9c986fb633594d974cedda643ceb8601c74f4b2c18
7
+ data.tar.gz: ee4b6abe4d93e40dabd416046b23fce7fea9a2596283fdcce523419eb33941c83855799b8201b32be22c21c554aed0212a50033ee45be56d91da197c8685c8aa
@@ -12,7 +12,8 @@ class Wco::Headline
12
12
  field :name
13
13
  validates :name, presence: true, uniqueness: true
14
14
 
15
- belongs_to :site, class_name: 'Wco::Site'
15
+ ## @TODO: remove this entirely. 2024-01-16
16
+ belongs_to :site, class_name: 'Wco::Site', optional: true
16
17
 
17
18
  has_and_belongs_to_many :tags, class_name: 'Wco::Tag'
18
19
 
@@ -23,9 +23,25 @@ class Wco::OfficeAction
23
23
 
24
24
  field :perform_at, type: :time
25
25
 
26
+ def do_run
27
+ sch = self
28
+ sch.update!({ status: STATUS_INACTIVE })
29
+
30
+ eval( sch.tmpl.action_exe )
31
+
32
+ # schedule next actions & update the action
33
+ sch.tmpl.ties.each do |tie|
34
+ next_sch = self.class.find_or_initialize_by({
35
+ office_action_template_id: tie.next_tmpl.id,
36
+ })
37
+ next_sch.perform_at = eval(tie.next_at_exe)
38
+ next_sch.status = STATUS_ACTIVE
39
+ next_sch.save!
40
+ end
41
+ end
42
+
26
43
  def to_s
27
44
  slug
28
45
  end
29
-
30
46
  end
31
47
 
@@ -7,10 +7,10 @@ class Wco::OfficeActionTemplateTie
7
7
  attr_accessor :to_delete
8
8
 
9
9
  belongs_to :office_action_template, class_name: 'OfficeActionTemplate', inverse_of: :ties
10
- def oat; office_action_template; end
10
+ def tmpl; office_action_template; end
11
11
 
12
12
  belongs_to :next_office_action_template, class_name: 'OfficeActionTemplate', inverse_of: :prev_ties
13
- def next_oat; next_office_action_template; end
13
+ def next_tmpl; next_office_action_template; end
14
14
  # def tmpl; next_office_action_template; end
15
15
 
16
16
 
@@ -1,5 +1,5 @@
1
1
 
2
- - oat ||= nil
2
+ - tmpl ||= nil
3
3
  - depth ||= 5
4
4
  - depth = depth - 1
5
5
 
@@ -10,9 +10,9 @@
10
10
  %li
11
11
  = tie.next_at_exe
12
12
  %br
13
- = link_to '[~]', edit_office_action_template_path(tie.next_oat)
14
- = link_to tie.next_oat, office_action_template_path(tie.next_oat)
15
- - if tie.next_oat == oat
13
+ = link_to '[~]', edit_office_action_template_path(tie.next_tmpl)
14
+ = link_to tie.next_tmpl, office_action_template_path(tie.next_tmpl)
15
+ - if tie.next_tmpl == tmpl
16
16
  <b>[Same]</b>
17
- - elsif tie.next_oat.ties.present?
18
- = render '/wco/office_action_templates/ties', ties: tie.next_oat.ties, depth: depth, oat: tie.next_oat
17
+ - elsif tie.next_tmpl.ties.present?
18
+ = render '/wco/office_action_templates/ties', ties: tie.next_tmpl.ties, depth: depth, tmpl: tie.next_tmpl
@@ -7,6 +7,8 @@
7
7
  &nbsp;
8
8
  = link_to oa.slug, office_action_path(oa)
9
9
  %ul
10
+ %li
11
+ .gray.mini= oa.id
10
12
  %li <b>status:</b> #{oa.status}
11
13
  %li
12
14
  <b>tmpl:</b>
@@ -2,34 +2,26 @@
2
2
  require 'business_time'
3
3
  require 'httparty'
4
4
 
5
- namespace :office do
5
+ namespace :wco do
6
6
 
7
- desc 'run_office_actions'
7
+
8
+ desc 'run office actions'
8
9
  task run_office_actions: :environment do
10
+ puts! "Starting wco_email:run_office_actions..."
9
11
  while true do
10
12
 
11
- OA = Wco::OfficeAction
12
- OAT = Wco::OfficeActionTemplate
13
-
14
- OA.active.where( :perform_at.lte => Time.now ).each do |oa|
15
- puts "+++ +++ Office Action: #{oa}"
13
+ schs = Wco::OfficeAction.active.where({ :perform_at.lte => Time.now })
14
+ print "[#{schs.length}]" if schs.length != 0
15
+ schs.each do |sch|
16
16
 
17
- oa.update({ status: INACTIVE })
18
- oa.tmpl.do_run
19
- oa.tmpl.ties.each do |tie|
20
- next_oa = OA.find_or_initialize_by({
21
- office_action_template_id: tie.next_oat.id,
22
- })
23
- next_oa.perform_at = eval( tie.next_at_exe )
24
- next_oa.status = ACTIVE
25
- next_oa.save!
26
- end
17
+ sch.do_run
27
18
 
28
- print '^'
19
+ print "[#{sch.id}]^"
20
+ sleep 15
29
21
  end
30
22
 
31
23
  print '.'
32
- sleep Rails.env.production? ? 60 : 5 # seconds
24
+ sleep 15
33
25
  end
34
26
  end
35
27
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.83
4
+ version: 3.1.0.85
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev