solid_queue_monitor 2.2.0 → 2.2.1
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 56966f46d6a81a73664fcad0850d60beeb87390264b9b2faf1a05d6031d38462
|
|
4
|
+
data.tar.gz: d064fc3683c29079fa20abd92e3d01487392de7d4c66d66bcd402571e8d059a3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 357596c47791d62224e737243db5fc183eb351988caffa55cedbe351f58562ff83c8fe8f3d65fdfcb1f3de976a890963d6aa1ad68cfb88037ff0d3410ec09160
|
|
7
|
+
data.tar.gz: aa2d8088de150fa65142d8b39088801c22b29f0fba914a74f4bf3240e2cd5017c9c48892c9ff5669a93f8526c767b0fe4146cf12b709485f726764af0d03cef6
|
|
@@ -61,7 +61,7 @@ module SolidQueueMonitor
|
|
|
61
61
|
# This works identically on PostgreSQL and SQLite.
|
|
62
62
|
def bucket_counts(model, column, start_time, end_time, interval, exclude_nil: false)
|
|
63
63
|
start_epoch = start_time.to_i
|
|
64
|
-
expr = bucket_index_expr(column, start_epoch, interval)
|
|
64
|
+
expr = bucket_index_expr(model, column, start_epoch, interval)
|
|
65
65
|
|
|
66
66
|
scope = model.where(column => start_time..end_time)
|
|
67
67
|
scope = scope.where.not(column => nil) if exclude_nil
|
|
@@ -82,18 +82,23 @@ module SolidQueueMonitor
|
|
|
82
82
|
# PostgreSQL: CAST((EXTRACT(EPOCH FROM col) - start) / interval AS INTEGER)
|
|
83
83
|
# SQLite: CAST((CAST(strftime('%s', col) AS INTEGER) - start) / interval AS INTEGER)
|
|
84
84
|
# MySQL: CAST((UNIX_TIMESTAMP(col) - start) / interval AS SIGNED)
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
#
|
|
86
|
+
# The adapter is detected from the model's own connection, not
|
|
87
|
+
# ActiveRecord::Base's. Solid Queue is commonly hosted on a dedicated
|
|
88
|
+
# database (config.solid_queue.connects_to), which may use a different
|
|
89
|
+
# engine than the host app's primary connection.
|
|
90
|
+
def bucket_index_expr(model, column, start_epoch, interval_seconds)
|
|
91
|
+
if adapter?(model, 'sqlite')
|
|
87
92
|
"CAST((CAST(strftime('%s', #{column}) AS INTEGER) - #{start_epoch}) / #{interval_seconds} AS INTEGER)"
|
|
88
|
-
elsif adapter?('mysql') || adapter?('trilogy')
|
|
93
|
+
elsif adapter?(model, 'mysql') || adapter?(model, 'trilogy')
|
|
89
94
|
"FLOOR((UNIX_TIMESTAMP(#{column}) - #{start_epoch}) / #{interval_seconds})"
|
|
90
95
|
else
|
|
91
96
|
"FLOOR((EXTRACT(EPOCH FROM #{column}) - #{start_epoch}) / #{interval_seconds})::integer"
|
|
92
97
|
end
|
|
93
98
|
end
|
|
94
99
|
|
|
95
|
-
def adapter?(name)
|
|
96
|
-
|
|
100
|
+
def adapter?(model, name)
|
|
101
|
+
model.connection.adapter_name.downcase.include?(name)
|
|
97
102
|
end
|
|
98
103
|
end
|
|
99
104
|
end
|