hirefire-resource 1.0.3 → 1.0.4

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: c60897b8911c796781d34001ae15a6eaa7a10baa884803858a235941acfbf438
4
- data.tar.gz: 52ea32f6080f388bac51855b68720dda3399127dba93180f559e22b458338737
3
+ metadata.gz: 1d0159499127d61d2281f345a3c4b50cb1a975012aed540d34a6463b53d5cc77
4
+ data.tar.gz: 6424c3fd3462880b0e2a635ddde4fefdce30740b4eee3edaabf7ff9d29a0a895
5
5
  SHA512:
6
- metadata.gz: d747c2ea92b9e9de7da34223ae65a1e04d3fd7a1c1f6f931ba8681b960c6060f117f2783650d9d3d4152b26a7ea5dfa0558d14e9137fb6a47799d29288ec7c26
7
- data.tar.gz: f515e6eeba0c96c3f0bce84c797ad21af39824cdc015f74ef011e3dad1d6124e08010e6c7609aebf27cd8a9470fec7f2a3c766d6b9cea9c2fba0b33cfef35497
6
+ metadata.gz: 60f7e44322babde5329e98b57c0698cd0ac9824f98cb4d83de30cd9dc750fdfb8845ddd8916a754d62011f397a2565afe437dd71b1d8f36ab4d8fa6f634cde96
7
+ data.tar.gz: f40b10e7e7d7a24824970f19a235619feec0171c374ca5a16ff5263c3a36996a44ad3088ab6aacee7cf8bf9abdf6175d8faa43cb5fc7bc2f4d255ce3ace0dd08
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v1.0.4
2
+
3
+ * Add support for `good_job ~> 4`, for the `job_queue_size`, `job_queue_latency` and `queue` (deprecated) macros.
4
+
1
5
  ## v1.0.3
2
6
 
3
7
  * Add support for `que ~> 0` and `que ~> 1`, in addition to `que ~> 2`, for both the `job_queue_size` and `job_queue_latency` macros.
@@ -1,11 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "hirefire/macro/helpers/good_job"
4
+
3
5
  module HireFire
4
6
  module Macro
5
7
  module Deprecated
6
8
  # Provides backward compatibility with the deprecated GoodJob macro.
7
9
  # For new implementations, refer to {HireFire::Macro::GoodJob}.
8
10
  module GoodJob
11
+ include HireFire::Macro::Helpers::GoodJob
12
+
9
13
  # Retrieves the total number of jobs in the specified queue(s) using GoodJob.
10
14
  #
11
15
  # This method queries the PostgreSQL database through GoodJob. It's capable
@@ -21,8 +25,7 @@ module HireFire
21
25
  # @example Counting jobs in the "default" queue
22
26
  # HireFire::Macro::GoodJob.queue("default")
23
27
  def queue(*queues)
24
- base_class = defined?(::GoodJob::Execution) ? ::GoodJob::Execution : ::GoodJob::Job
25
- scope = base_class.only_scheduled.unfinished
28
+ scope = good_job_class.only_scheduled.unfinished
26
29
  scope = scope.where(queue_name: queues) if queues.any?
27
30
  scope.count
28
31
  end
@@ -1,12 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "helpers/good_job"
3
4
  require_relative "deprecated/good_job"
4
5
 
5
6
  module HireFire
6
7
  module Macro
7
8
  module GoodJob
8
- extend HireFire::Macro::Deprecated::GoodJob
9
9
  extend HireFire::Utility
10
+ extend HireFire::Macro::Helpers::GoodJob
11
+ extend HireFire::Macro::Deprecated::GoodJob
10
12
  extend self
11
13
 
12
14
  # Calculates the maximum job queue latency using GoodJob. If no queues are specified, it
@@ -23,9 +25,9 @@ module HireFire
23
25
  # HireFire::Macro::GoodJob.job_queue_latency(:default, :mailer)
24
26
  def job_queue_latency(*queues)
25
27
  queues = normalize_queues(queues, allow_empty: true)
26
- query = ::GoodJob::Execution
28
+ query = good_job_class
27
29
  query = query.where(queue_name: queues) if queues.any?
28
- query = query.where(finished_at: nil)
30
+ query = query.where(performed_at: nil)
29
31
  query = query.where(scheduled_at: ..Time.now).or(query.where(scheduled_at: nil))
30
32
  query = query.order(scheduled_at: :asc, created_at: :asc)
31
33
 
@@ -50,9 +52,9 @@ module HireFire
50
52
  # HireFire::Macro::GoodJob.job_queue_size(:default, :mailer)
51
53
  def job_queue_size(*queues)
52
54
  queues = normalize_queues(queues, allow_empty: true)
53
- query = ::GoodJob::Execution
55
+ query = good_job_class
54
56
  query = query.where(queue_name: queues) if queues.any?
55
- query = query.where(finished_at: nil)
57
+ query = query.where(performed_at: nil)
56
58
  query = query.where(scheduled_at: ..Time.now).or(query.where(scheduled_at: nil))
57
59
  query.count
58
60
  end
@@ -0,0 +1,19 @@
1
+ module HireFire
2
+ module Macro
3
+ module Helpers
4
+ module GoodJob
5
+ def self.included(base)
6
+ base.send(:private, :good_job_class)
7
+ end
8
+
9
+ def good_job_class
10
+ if Gem::Version.new(::GoodJob::VERSION) >= Gem::Version.new("4.0.0")
11
+ ::GoodJob::Job
12
+ else
13
+ ::GoodJob::Execution
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HireFire
4
- VERSION = "1.0.3"
4
+ VERSION = "1.0.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hirefire-resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael van Rooijen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-23 00:00:00.000000000 Z
11
+ date: 2024-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal
@@ -50,6 +50,7 @@ files:
50
50
  - lib/hirefire/macro/deprecated/resque.rb
51
51
  - lib/hirefire/macro/deprecated/sidekiq.rb
52
52
  - lib/hirefire/macro/good_job.rb
53
+ - lib/hirefire/macro/helpers/good_job.rb
53
54
  - lib/hirefire/macro/que.rb
54
55
  - lib/hirefire/macro/queue_classic.rb
55
56
  - lib/hirefire/macro/resque.rb
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  - !ruby/object:Gem::Version
87
88
  version: '0'
88
89
  requirements: []
89
- rubygems_version: 3.5.9
90
+ rubygems_version: 3.5.11
90
91
  signing_key:
91
92
  specification_version: 4
92
93
  summary: HireFire integration library for Ruby applications