judoscale-good_job 1.7.1 → 1.8.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: c0f5d1258c1984ca9b01d8f13fd925cdaf3e3ea1d4f930619f0ace8360a715e7
4
- data.tar.gz: 77076fa9d655f651231208ee4021a9f728f9497d26f3cf2c7082e796d238863e
3
+ metadata.gz: dac87de18dfef986786bf05140ce577ad215ee07096dbed0a236165925c62098
4
+ data.tar.gz: 6e8a9c2131e19295869fc354c71160ee4bf6a913d674c0cf7bf827875b389685
5
5
  SHA512:
6
- metadata.gz: e43107bce2519b653db1cbe2267d242bc8aa5e68a35857bc6420689e667b0f8c7cd75a7d430574957572c8f47dc37c266de6eb91e04034b18fdd95301924eedd
7
- data.tar.gz: 064d96dec45d79e74111a52a652f8a933bae3093d7d2810d2ed4d49a170b3e2a72bc8c24e189396bc0d6cddb22221b2f3b0afa387e5b867ad72088b315fd9b19
6
+ metadata.gz: 225bd45625c073cdff0c306aa741281ca4e9aadfe7287b73f781531e29fe6997936135838f8b44d0b5a3391f84d9fe968746682ccb76f3b4fe0ed3a8f74433c7
7
+ data.tar.gz: 9a64e9bc3fb6b4a7649cc23889021b4e7bc5b850f1c3967ce028d410134f1f4f15c5dc1db6f274b457939f722575e38a09150315213bedb2f24ec2c0d4c49e7d
@@ -9,19 +9,29 @@ module Judoscale
9
9
  class MetricsCollector < Judoscale::JobMetricsCollector
10
10
  include ActiveRecordHelper
11
11
 
12
+ def self.good_job_v4?
13
+ Gem::Version.new(::GoodJob::VERSION) >= Gem::Version.new("4")
14
+ end
15
+
16
+ def self.good_job_base_class
17
+ good_job_v4? ? ::GoodJob::Job : ::GoodJob::Execution
18
+ end
19
+
12
20
  def self.adapter_config
13
21
  Judoscale::Config.instance.good_job
14
22
  end
15
23
 
16
24
  def self.collect?(config)
17
- super && ActiveRecordHelper.table_exists_for_model?(::GoodJob::Execution)
25
+ super && ActiveRecordHelper.table_exists_for_model?(good_job_base_class)
18
26
  end
19
27
 
20
28
  def initialize
21
29
  super
22
30
 
31
+ @good_job_base_class = self.class.good_job_base_class
32
+
23
33
  queue_names = run_silently do
24
- ::GoodJob::Execution.select("distinct queue_name").map(&:queue_name)
34
+ @good_job_base_class.select("distinct queue_name").map(&:queue_name)
25
35
  end
26
36
  self.queues |= queue_names
27
37
  end
@@ -32,7 +42,7 @@ module Judoscale
32
42
 
33
43
  # logically we don't need the finished_at condition, but it lets postgres use the indexes
34
44
  oldest_execution_time_by_queue = run_silently do
35
- ::GoodJob::Execution
45
+ @good_job_base_class
36
46
  .where(performed_at: nil, finished_at: nil)
37
47
  .group(:queue_name)
38
48
  .pluck(:queue_name, Arel.sql("min(coalesce(scheduled_at, created_at))"))
@@ -42,7 +52,7 @@ module Judoscale
42
52
 
43
53
  if track_busy_jobs?
44
54
  busy_count_by_queue = run_silently do
45
- ::GoodJob::Execution.running.group(:queue_name).count
55
+ @good_job_base_class.running.group(:queue_name).count
46
56
  end
47
57
  self.queues |= busy_count_by_queue.keys
48
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: judoscale-good_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam McCrea
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-07-08 00:00:00.000000000 Z
13
+ date: 2024-07-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: judoscale-ruby
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.7.1
21
+ version: 1.8.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 1.7.1
28
+ version: 1.8.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: good_job
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -35,7 +35,7 @@ dependencies:
35
35
  version: '3.0'
36
36
  - - "<"
37
37
  - !ruby/object:Gem::Version
38
- version: '4.0'
38
+ version: '5.0'
39
39
  type: :runtime
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
@@ -45,7 +45,7 @@ dependencies:
45
45
  version: '3.0'
46
46
  - - "<"
47
47
  - !ruby/object:Gem::Version
48
- version: '4.0'
48
+ version: '5.0'
49
49
  description:
50
50
  email:
51
51
  - hello@judoscale.com