crono_trigger 0.2.0 → 0.3.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fab2315a80e4be9236cf9434376391a1c6094db
|
4
|
+
data.tar.gz: 81c83e45ab1dc7807da2aa37b32ae7a2eae29be2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70ae8e8e74eb754c58276dd009ba7b186039f47bbf06271040e274e1c7f636048a90bf6583aea7541b961e001ccb1a898583de320415afc69d3abfb29bcfb15c
|
7
|
+
data.tar.gz: a98c18cd51895f6cdfc190988cd66990b405875b8daec137f74e51d4f72d4caac643b5622adf7fdc14b8544840254a916b0a88624fd4c454cf3004bb75ae7619
|
data/README.md
CHANGED
@@ -122,7 +122,7 @@ $ crono_trigger MailNotification
|
|
122
122
|
$ crono_trigger --help
|
123
123
|
Usage: crono_trigger [options] MODEL [MODEL..]
|
124
124
|
-f, --config-file=CONFIG Config file (ex. ./crono_trigger.rb)
|
125
|
-
-e, --
|
125
|
+
-e, --environment=ENV Set environment name (ex. development, production)
|
126
126
|
-p, --polling-thread=SIZE Polling thread size (Default: 1)
|
127
127
|
-i, --polling-interval=SECOND Polling interval seconds (Default: 5)
|
128
128
|
-c, --concurrency=SIZE Execute thread size (Default: 25)
|
data/lib/crono_trigger/cli.rb
CHANGED
@@ -14,7 +14,7 @@ opt_parser = OptionParser.new do |opts|
|
|
14
14
|
options[:config] = cfg
|
15
15
|
end
|
16
16
|
|
17
|
-
opts.on("-e", "--
|
17
|
+
opts.on("-e", "--environment=ENV", "Set environment name (ex. development, production)") do |env|
|
18
18
|
options[:env] = env
|
19
19
|
end
|
20
20
|
|
@@ -114,12 +114,21 @@ module CronoTrigger
|
|
114
114
|
def activate_schedule!(at: Time.current)
|
115
115
|
time = calculate_next_execute_at || at
|
116
116
|
|
117
|
+
attributes = {}
|
118
|
+
unless self[crono_trigger_column_name(:next_execute_at)]
|
119
|
+
attributes[crono_trigger_column_name(:next_execute_at)] = time
|
120
|
+
end
|
121
|
+
|
122
|
+
if self.class.column_names.include?(crono_trigger_column_name(:started_at))
|
123
|
+
unless self[crono_trigger_column_name(:started_at)]
|
124
|
+
attributes[crono_trigger_column_name(:started_at)] = time
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
117
128
|
if new_record?
|
118
|
-
self
|
129
|
+
self.attributes = attributes
|
119
130
|
else
|
120
|
-
|
121
|
-
update_column(crono_trigger_column_name(:next_execute_at), time)
|
122
|
-
end
|
131
|
+
update_columns(attributes)
|
123
132
|
end
|
124
133
|
end
|
125
134
|
|
@@ -185,7 +194,7 @@ module CronoTrigger
|
|
185
194
|
def calculate_next_execute_at(now = Time.current)
|
186
195
|
if self[crono_trigger_column_name(:cron)]
|
187
196
|
tz = self[crono_trigger_column_name(:timezone)].try { |zn| TZInfo::Timezone.get(zn) }
|
188
|
-
base = [now, self[crono_trigger_column_name(:started_at)]].max
|
197
|
+
base = [now, self[crono_trigger_column_name(:started_at)]].compact.max
|
189
198
|
cron_now = tz ? base.in_time_zone(tz) : base
|
190
199
|
Chrono::NextTime.new(now: cron_now, source: self[crono_trigger_column_name(:cron)]).to_time
|
191
200
|
end
|
@@ -28,7 +28,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration<%= Rails::VERSION::M
|
|
28
28
|
t.timestamps<%= Rails::VERSION::MAJOR >=5 ? " null: false" : "" %>
|
29
29
|
<% end -%>
|
30
30
|
end
|
31
|
-
|
31
|
+
<% attributes.select { |attribute| attribute.respond_to?(:token?) && attribute.token? }.each do |attribute| -%>
|
32
32
|
add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>, unique: true
|
33
33
|
<% end -%>
|
34
34
|
<% attributes_with_index.each do |attribute| -%>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crono_trigger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- joker1007
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chrono
|
@@ -236,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
236
|
version: '0'
|
237
237
|
requirements: []
|
238
238
|
rubyforge_project:
|
239
|
-
rubygems_version: 2.6.
|
239
|
+
rubygems_version: 2.6.13
|
240
240
|
signing_key:
|
241
241
|
specification_version: 4
|
242
242
|
summary: In Service Asynchronous Job Scheduler for Rails
|