solid_queue_monitor 1.2.0 → 1.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: bc739f10c21ca234c61c65a5b94d9c548cfc8d332dac0d1db3311d0d113fe035
4
- data.tar.gz: 4a131b01c6c3e330b46413029278dbcee09e4f6410f1edf44b14da5902ec5b1a
3
+ metadata.gz: 6de5c6ef734c44e24c72e13d194fa9e6243fa5cefce591f430daa6f6dc1f175d
4
+ data.tar.gz: 7065afd18960ef8f61b7131fa96fd7c46120b75c52c2b633a34f63b686b8ca2c
5
5
  SHA512:
6
- metadata.gz: 02b79913620ac69eb63c15b2c92a1ba76f44f981036f977eb72fe684faa28ae2057ea187582e8bbd5cb09c0de9f030be89e07b8e8e8e754ee0ffebd6e7c33f84
7
- data.tar.gz: 853dc16edd433afa568a7cef1efb78b295d54595a72e1e7c177e7991ff50b3e396d80ab1092754e65972dbe0fa9072e2a4563ab68b4785ebe7b5d77b5373e086
6
+ metadata.gz: 6e899fddd4e1b08cf84beeff8b93f8ca67c199ce98d795983335300bf15fc087fe8ab0009d2a75746ae4d90b68f0b609f03c7ca44fb50ac0784551fc1e111a6b
7
+ data.tar.gz: eecbd91a4eee221f13431810542e92c3fa06403d2279a00e447e186c00a4d34479c134461864c80274171493c985d83d4ea7ac351e93dc09d13238d00ee825d6
data/README.md CHANGED
@@ -104,9 +104,11 @@ SolidQueueMonitor.setup do |config|
104
104
  config.authentication_enabled = false
105
105
 
106
106
  # Set the username for HTTP Basic Authentication (only used if authentication is enabled)
107
+ # Supports static values, ENV variables, or callables (Proc/Lambda)
107
108
  config.username = 'admin'
108
109
 
109
110
  # Set the password for HTTP Basic Authentication (only used if authentication is enabled)
111
+ # Supports static values, ENV variables, or callables (Proc/Lambda)
110
112
  config.password = 'password'
111
113
 
112
114
  # Number of jobs to display per page
@@ -141,7 +143,21 @@ By default, Solid Queue Monitor does not require authentication to access the da
141
143
  For production environments, it's strongly recommended to enable authentication:
142
144
 
143
145
  1. **Enable authentication**: Set `config.authentication_enabled = true` in the initializer
144
- 2. **Configure secure credentials**: Set `username` and `password` to strong values in the initializer
146
+ 2. **Configure secure credentials** using any of these approaches:
147
+
148
+ ```ruby
149
+ # Static values
150
+ config.username = 'admin'
151
+ config.password = 'secure_password'
152
+
153
+ # Environment variables
154
+ config.username = ENV['SOLID_QUEUE_MONITOR_USERNAME']
155
+ config.password = ENV['SOLID_QUEUE_MONITOR_PASSWORD']
156
+
157
+ # Rails credentials (use a lambda for deferred evaluation)
158
+ config.username = -> { Rails.application.credentials.dig(:solid_queue_monitor, :username) }
159
+ config.password = -> { Rails.application.credentials.dig(:solid_queue_monitor, :password) }
160
+ ```
145
161
 
146
162
  ## Usage
147
163
 
@@ -81,16 +81,19 @@ module SolidQueueMonitor
81
81
  # Cross-DB bucket index expression.
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
+ # MySQL: CAST((UNIX_TIMESTAMP(col) - start) / interval AS SIGNED)
84
85
  def bucket_index_expr(column, start_epoch, interval_seconds)
85
- if sqlite?
86
+ if adapter?('sqlite')
86
87
  "CAST((CAST(strftime('%s', #{column}) AS INTEGER) - #{start_epoch}) / #{interval_seconds} AS INTEGER)"
88
+ elsif adapter?('mysql')
89
+ "CAST((UNIX_TIMESTAMP(#{column}) - #{start_epoch}) / #{interval_seconds} AS SIGNED)"
87
90
  else
88
91
  "CAST((EXTRACT(EPOCH FROM #{column}) - #{start_epoch}) / #{interval_seconds} AS INTEGER)"
89
92
  end
90
93
  end
91
94
 
92
- def sqlite?
93
- ActiveRecord::Base.connection.adapter_name.downcase.include?('sqlite')
95
+ def adapter?(name)
96
+ ActiveRecord::Base.connection.adapter_name.downcase.include?(name)
94
97
  end
95
98
  end
96
99
  end
@@ -7,9 +7,13 @@ SolidQueueMonitor.setup do |config|
7
7
 
8
8
  # Set the username for HTTP Basic Authentication (only used if authentication is enabled)
9
9
  # config.username = 'admin'
10
+ # config.username = ENV['SOLID_QUEUE_MONITOR_USERNAME']
11
+ # config.username = -> { Rails.application.credentials.dig(:solid_queue_monitor, :username) }
10
12
 
11
13
  # Set the password for HTTP Basic Authentication (only used if authentication is enabled)
12
14
  # config.password = 'password'
15
+ # config.password = ENV['SOLID_QUEUE_MONITOR_PASSWORD']
16
+ # config.password = -> { Rails.application.credentials.dig(:solid_queue_monitor, :password) }
13
17
 
14
18
  # Number of jobs to display per page
15
19
  # config.jobs_per_page = 25
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidQueueMonitor
4
- VERSION = '1.2.0'
4
+ VERSION = '1.2.1'
5
5
  end
@@ -6,8 +6,23 @@ require_relative 'solid_queue_monitor/engine'
6
6
  module SolidQueueMonitor
7
7
  class Error < StandardError; end
8
8
  class << self
9
- attr_accessor :username, :password, :jobs_per_page, :authentication_enabled,
9
+ attr_writer :username, :password
10
+ attr_accessor :jobs_per_page, :authentication_enabled,
10
11
  :auto_refresh_enabled, :auto_refresh_interval, :show_chart
12
+
13
+ def username
14
+ resolve_value(@username)
15
+ end
16
+
17
+ def password
18
+ resolve_value(@password)
19
+ end
20
+
21
+ private
22
+
23
+ def resolve_value(value)
24
+ value.respond_to?(:call) ? value.call : value
25
+ end
11
26
  end
12
27
 
13
28
  @username = 'admin'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_queue_monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vishal Sadriya