que-scheduler 4.6.0 → 5.1.0

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: a2e01f6eaa026842cf6f2041b3f979e571ca455427cdd70c8609d4f2a6c561a6
4
- data.tar.gz: 3acb6027f4d8508f7fc7cbc2e27d55442783f4dcb3d855645bfb5e8db9054ad8
3
+ metadata.gz: ba72652aebf9c4fb8c0f07702d03fdb2a119c54ed4b900c309acdf5a7200bdc4
4
+ data.tar.gz: a83083a1c0fb05be711857c255bd18c1870f707522d070363def5b2de22271b3
5
5
  SHA512:
6
- metadata.gz: e7c0eae15faf60069fc997a37d73c8521ab441e257ec18689d26b5cabc6fb7165a83207c54eee8890e4db43aac673263ef81072f9b7541bbbf12a45c427547ef
7
- data.tar.gz: 2218a3e0b28e4d64ad7f7fc807ddff0761c46344b89e762e127dd49e833a5e2c11d6ed59726a8f0eba1b2fa10855b73415dc1a964819de5dcf1109be43d4349a
6
+ metadata.gz: caf4f8b82b646f78cf133d8bc8bf78eed5609517a29275a0c27558c05732435393b51479a825b1004c6d980cd3365657b6ff7a7e7393f61497579ad4dbaf769c
7
+ data.tar.gz: 49eb2acebbe74606970f06d2df9cdff5dbf482233382f9237c459f3ccc5e61d6cee065fd6060974e04f748a6c72391db3369ac966aa5e60a1f3a621bdd6d9cc8
data/README.md CHANGED
@@ -25,9 +25,9 @@ resque-scheduler files, but with additional features.
25
25
  will fail if Que is set to execute jobs synchronously, i.e. `Que::Job.run_synchronously = true`.
26
26
 
27
27
  ```ruby
28
- class CreateQueSchedulerSchema < ActiveRecord::Migration
28
+ class CreateQueSchedulerSchema < ActiveRecord::Migration[6.0]
29
29
  def change
30
- Que::Scheduler::Migrations.migrate!(version: 7)
30
+ Que::Scheduler::Migrations.migrate!(version: 8)
31
31
  end
32
32
  end
33
33
  ```
@@ -210,23 +210,25 @@ ie, This will perform all migrations necessary up to the latest version, skippin
210
210
  performed.
211
211
 
212
212
  ```ruby
213
- class CreateQueSchedulerSchema < ActiveRecord::Migration
213
+ class CreateQueSchedulerSchema < ActiveRecord::Migration[6.0]
214
214
  def change
215
- Que::Scheduler::Migrations.migrate!(version: 7)
215
+ Que::Scheduler::Migrations.migrate!(version: 8)
216
216
  end
217
217
  end
218
218
  ```
219
219
 
220
220
  The changes in past migrations were:
221
221
 
222
- | Version | Changes |
223
- |:-------:|---------------------------------------------------------------------------------|
224
- | 1 | Enqueued the main Que::Scheduler. This is the job that performs the scheduling. |
225
- | 2 | Added the audit table `que_scheduler_audit`. |
226
- | 3 | Added the audit table `que_scheduler_audit_enqueued`. |
227
- | 4 | Updated the the audit tables to use bigints |
228
- | 5 | Dropped an unnecessary index |
229
- | 6 | Enforced single scheduler job at the trigger level |
222
+ | Version | Changes |
223
+ |:-------:|-------------------------------------------------------------------------------------|
224
+ | 1 | Enqueued the main Que::Scheduler. This is the job that performs the scheduling. |
225
+ | 2 | Added the audit table `que_scheduler_audit`. |
226
+ | 3 | Added the audit table `que_scheduler_audit_enqueued`. |
227
+ | 4 | Updated the the audit tables to use bigints |
228
+ | 5 | Dropped an unnecessary index |
229
+ | 6 | Enforced single scheduler job at the trigger level |
230
+ | 7 | Prevent accidental deletion of scheduler job |
231
+ | 8 | Add primary key to audit. Note, this can be a slow migration if you have many rows! |
230
232
 
231
233
  The changes to the DB ([DDL](https://en.wikipedia.org/wiki/Data_definition_language)) are all
232
234
  captured in the structure.sql so will be re-run in correctly if squashed - except for the actual
@@ -0,0 +1 @@
1
+ ALTER TABLE que_scheduler_audit_enqueued DROP COLUMN "id";
@@ -0,0 +1 @@
1
+ ALTER TABLE que_scheduler_audit_enqueued ADD COLUMN id BIGSERIAL PRIMARY KEY;
@@ -10,6 +10,7 @@ module Que
10
10
  assert_db_migrated
11
11
  end
12
12
 
13
+ # rubocop:disable Metrics/MethodLength
13
14
  private def assert_db_migrated
14
15
  db_version = Que::Scheduler::Migrations.db_version
15
16
  return if db_version == Que::Scheduler::Migrations::MAX_VERSION
@@ -47,7 +48,7 @@ module Que
47
48
  To bring the db version up to the current one required, add a migration like this. It
48
49
  is cumulative, so one line is sufficient to perform all necessary steps.
49
50
 
50
- class UpdateQueSchedulerSchema < ActiveRecord::Migration
51
+ class UpdateQueSchedulerSchema < ActiveRecord::Migration[6.0]
51
52
  def change
52
53
  Que::Scheduler::Migrations.migrate!(version: #{Que::Scheduler::Migrations::MAX_VERSION})
53
54
  end
@@ -57,6 +58,7 @@ module Que
57
58
  synchronously. This will fail as que-scheduler needs the above tables to work.
58
59
  ERR
59
60
  end
61
+ # rubocop:enable Metrics/MethodLength
60
62
  end
61
63
  end
62
64
  end
@@ -96,18 +96,7 @@ module Que
96
96
  # be used when the job is worked.
97
97
  data = JSON.parse(job.to_json, symbolize_names: true)
98
98
 
99
- # ActiveJob scheduled_at is returned as a float, where we want a Time for consistency
100
- scheduled_at =
101
- begin
102
- scheduled_at_float = data[:scheduled_at]
103
- # rubocop:disable Style/EmptyElse
104
- if scheduled_at_float
105
- Que::Scheduler::TimeZone.time_zone.at(scheduled_at_float)
106
- else
107
- nil
108
- end
109
- # rubocop:enable Style/EmptyElse
110
- end
99
+ scheduled_at = self.class.extract_scheduled_at(data[:scheduled_at])
111
100
 
112
101
  # Rails didn't support queues for ActiveJob for a while
113
102
  used_queue = data[:queue_name] if ToEnqueue.active_job_version_supports_queues?
@@ -142,6 +131,22 @@ module Que
142
131
  job_class_set.perform_later(*args)
143
132
  end
144
133
  end
134
+
135
+ class << self
136
+ # ActiveJob scheduled_at is returned as a float, or a string post Rails 7.1,
137
+ # and we want a Time for consistency
138
+ def extract_scheduled_at(scheduled_at)
139
+ # rubocop:disable Style/EmptyElse
140
+ if scheduled_at.is_a?(Float)
141
+ Que::Scheduler::TimeZone.time_zone.at(scheduled_at)
142
+ elsif scheduled_at.is_a?(String)
143
+ Que::Scheduler::TimeZone.time_zone.parse(scheduled_at)
144
+ else
145
+ nil
146
+ end
147
+ # rubocop:enable Style/EmptyElse
148
+ end
149
+ end
145
150
  end
146
151
 
147
152
  # A value object returned after a job has been enqueued. This is necessary as Que (normal) and
@@ -1,5 +1,5 @@
1
1
  module Que
2
2
  module Scheduler
3
- VERSION = "4.6.0".freeze
3
+ VERSION = "5.1.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: que-scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.6.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Lascelles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-10 00:00:00.000000000 Z
11
+ date: 2024-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -401,6 +401,8 @@ files:
401
401
  - lib/que/scheduler/migrations/6/up.sql
402
402
  - lib/que/scheduler/migrations/7/down.sql
403
403
  - lib/que/scheduler/migrations/7/up.sql
404
+ - lib/que/scheduler/migrations/8/down.sql
405
+ - lib/que/scheduler/migrations/8/up.sql
404
406
  - lib/que/scheduler/schedule.rb
405
407
  - lib/que/scheduler/scheduler_job.rb
406
408
  - lib/que/scheduler/scheduler_job_args.rb