postburner 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/app/models/postburner/job.rb +21 -11
- data/lib/postburner/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca9bed4afd8b585d14934b4ba09b20c58109d8de39d5300d135069e2723c3aba
|
4
|
+
data.tar.gz: 5ae5f4a07e53ac69b4d4b795f3b8c8bdf5b9a087e1a8513f6fed03cb47e48210
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c741884d62b1b71b7c8ce928baff5fef35054c58962f530ee06764b4947477ca394712300256e98409187494092c7164a5f8490482e54a19d0f1776b8465f783
|
7
|
+
data.tar.gz: 193a2e625139d0a441503afc15d64888eb25234d0ae81ca320a319506130e8eb1c960141d60b97066633f6a777ab47fe21d49d42bc448497b4225e8c78924051
|
data/CHANGELOG.md
CHANGED
@@ -24,25 +24,31 @@ module Postburner
|
|
24
24
|
|
25
25
|
before_validation :ensure_sid!
|
26
26
|
before_destroy :delete!
|
27
|
+
after_save_commit :insert_if_queued!
|
27
28
|
|
28
29
|
validates :sid, presence: {strict: true}
|
29
30
|
|
30
31
|
def queue!(options={})
|
31
32
|
return if self.queued_at.present? && self.bkid.present?
|
33
|
+
raise ActiveRecord::RecordInvalid, "Can't queue unless valid." unless self.valid?
|
34
|
+
at = options.delete(:at)
|
32
35
|
|
33
|
-
self.
|
36
|
+
self.run_at = case
|
37
|
+
when at.present?
|
38
|
+
# this is rudimentary, add error handling
|
39
|
+
options[:delay] ||= at.to_i - Time.zone.now.to_i
|
40
|
+
at
|
41
|
+
when options[:delay].present?
|
42
|
+
Time.zone.now + options[:delay].seconds
|
43
|
+
end
|
34
44
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
update_column :run_at, options[:at]
|
40
|
-
options.delete(:at)
|
41
|
-
when options[:delay].present?
|
42
|
-
update_column :run_at, Time.zone.now + options[:delay].seconds
|
43
|
-
end
|
45
|
+
@_insert_options = options
|
46
|
+
|
47
|
+
self.save!
|
48
|
+
end
|
44
49
|
|
45
|
-
|
50
|
+
def will_insert?
|
51
|
+
@_insert_options.is_a? Hash
|
46
52
|
end
|
47
53
|
|
48
54
|
# tube: backburner.worker.queue.backburner-jobs
|
@@ -224,6 +230,10 @@ module Postburner
|
|
224
230
|
}.merge(data))
|
225
231
|
end
|
226
232
|
|
233
|
+
def insert_if_queued!
|
234
|
+
return unless self.will_insert?
|
235
|
+
insert!(@_insert_options)
|
236
|
+
end
|
227
237
|
|
228
238
|
def insert!(options={})
|
229
239
|
response = Backburner::Worker.enqueue(
|
data/lib/postburner/version.rb
CHANGED