libis-workflow-mongoid 2.0.13 → 2.0.15

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
  SHA1:
3
- metadata.gz: 7ff731d84990f95728323e0a6fdd1c7ddccfacd6
4
- data.tar.gz: 3bfdf421a6ad400bef46584cf5d52dbe6c22d330
3
+ metadata.gz: b3ff5f51a5e475651b8d8ad4c994ba59a6cd2e92
4
+ data.tar.gz: 5ec123c0adb36feeef0772b0a577565b81093c3a
5
5
  SHA512:
6
- metadata.gz: 8eac4a86f2b38c52699d951a1cb3037ad385a89fbab1aaf1280f8667bbcf9bd5dacb9476bcea87e9d56231a7bdade572bec7e140160a1d11c4b949dc04cb0ca9
7
- data.tar.gz: a0e1206ac0063fc85ff9cf7f65e7500a01c11cbeefbc45f56be7f1ba0d6b7d4f2458ea16cac9f25c774f6d793738ce44b199c0a288048ac7282181c783b9bfcb
6
+ metadata.gz: 77b1a1f1d3c860ccf8682f369e528b404a5a6faef9309cafe92ad8ddd0f95e28780a3dfce6bdbca9c257426230d111e396c950fe0ac5750e2b1d7bc4eb931f71
7
+ data.tar.gz: 4b8ed290d124e27db2676c62bda5a324e4a1ccd744275a05720ec3492ad40755f6afa0a5fb0e17e815662d42cd42e1cf3b0d4739b6f3111f5de9a21f8151a1ff
@@ -9,15 +9,16 @@ module Libis
9
9
 
10
10
  class StatusEntry
11
11
  include ::Mongoid::Document
12
- include ::Mongoid::Timestamps::Short
13
12
 
14
13
  field :task, type: String
14
+ field :created, type: DateTime, default: -> { DateTime.now }
15
+ field :updated, type: DateTime
15
16
  field :status, type: String, default: 'STARTED'
16
17
  field :progress, type: Integer
17
18
  field :max, type: Integer
18
19
 
19
- index({c_at: 1}, {name: 'by_created'})
20
- index({u_at: 1}, {name: 'by_updated'})
20
+ index({created: 1}, {name: 'by_created'})
21
+ index({updated: 1}, {name: 'by_updated'})
21
22
 
22
23
  embedded_in :item, polymorphic: true
23
24
  end
@@ -1,7 +1,7 @@
1
1
  module Libis
2
2
  module Workflow
3
3
  module Mongoid
4
- VERSION = '2.0.13' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
4
+ VERSION = '2.0.15' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
5
5
  end
6
6
  end
7
7
  end
@@ -14,11 +14,10 @@ module Libis
14
14
  field :options, type: Hash, default: -> { Hash.new }
15
15
  field :properties, type: Hash, default: -> { Hash.new }
16
16
  field :summary, type: Hash, default: -> { Hash.new }
17
+ field :status_log, type: Array, default: -> { Array.new }
17
18
 
18
19
  index({_id: 1, _type: 1}, {unique: true, name: 'by_id'})
19
20
 
20
- embeds_many :status_log, as: :item, class_name: Libis::Workflow::Mongoid::StatusEntry.to_s
21
-
22
21
  has_many :items, as: :parent, class_name: Libis::Workflow::Mongoid::WorkItem.to_s,
23
22
  dependent: :destroy, autosave: true, order: :c_at.asc
24
23
 
@@ -37,28 +36,12 @@ module Libis
37
36
  self.items.to_a
38
37
  end
39
38
 
40
- def status_progress(task, progress = 0, max = nil)
41
- log_entry = status_entry(task)
42
- log_entry ||= self.status_log.build(task: task)
43
- log_entry[:progress] = progress
44
- log_entry[:max] = max if max
45
- end
46
-
47
39
  protected
48
40
 
49
- # Get last known status entry for a given task
50
- #
51
- # In the Mongid storage, we retrieve the status log in date descending order, so we retrieve the first item.
52
- # @param [String] task task name to check item status for
53
- # @return [Hash] the status entry
54
- def status_entry(task = nil)
55
- task.nil? ?
56
- self.status_log.order_by(u_at: -1).first :
57
- self.status_log.order_by(u_at: -1).where(task: task).first
58
- end
59
-
60
41
  def add_status_log(info)
61
- self.status_log.build(info)
42
+ # noinspection RubyResolve
43
+ self.status_log << info
44
+ self.status_log.last
62
45
  end
63
46
 
64
47
  end
@@ -8,7 +8,6 @@ module Libis
8
8
 
9
9
  autoload :Base, 'libis/workflow/mongoid/base'
10
10
  autoload :Config, 'libis/workflow/mongoid/config'
11
- autoload :LogEntry, 'libis/workflow/mongoid/log_entry'
12
11
  autoload :StatusEntry, 'libis/workflow/mongoid/status_entry'
13
12
  autoload :Job, 'libis/workflow/mongoid/job'
14
13
  autoload :WorkItem, 'libis/workflow/mongoid/work_item'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libis-workflow-mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.13
4
+ version: 2.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Dekeyser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-15 00:00:00.000000000 Z
11
+ date: 2016-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libis-workflow
@@ -115,7 +115,6 @@ files:
115
115
  - lib/libis/workflow/mongoid/config.rb
116
116
  - lib/libis/workflow/mongoid/dynamic.rb
117
117
  - lib/libis/workflow/mongoid/job.rb
118
- - lib/libis/workflow/mongoid/log_entry.rb
119
118
  - lib/libis/workflow/mongoid/run.rb
120
119
  - lib/libis/workflow/mongoid/sequence.rb
121
120
  - lib/libis/workflow/mongoid/status_entry.rb
@@ -1,32 +0,0 @@
1
- require 'libis-workflow'
2
- require 'libis/workflow/mongoid/base'
3
-
4
- require 'mongoid/extensions/time_with_zone'
5
-
6
- module Libis
7
- module Workflow
8
- module Mongoid
9
-
10
- class LogEntry
11
- include ::Mongoid::Document
12
- include ::Mongoid::Timestamps::Created::Short
13
-
14
- store_in collection: 'log'
15
-
16
- field :severity, type: String
17
- field :task, type: String, default: ''
18
- field :code, type: Integer
19
- field :message, type: String
20
- field :run_id
21
-
22
- index({c_at: 1}, {name: 'by_created'})
23
- index({logger_type: 1, logger_id: 1, c_at: 1, }, {background: true, name: 'by_logger'})
24
- index({logger_type: 1, logger_id: 1, c_at: 1, task: 1}, {background: true, name: 'by_task'})
25
-
26
- belongs_to :logger, polymorphic: true
27
-
28
- end
29
-
30
- end
31
- end
32
- end