Class: Tasker::Functions::FunctionBasedSystemHealthCounts
- Inherits:
-
FunctionWrapper
- Object
- FunctionWrapper
- Tasker::Functions::FunctionBasedSystemHealthCounts
- Defined in:
- lib/tasker/functions/function_based_system_health_counts.rb
Overview
Wrapper for the get_system_health_counts_v01 SQL function
This function provides comprehensive system health metrics in a single query, returning counts for tasks, steps, retry states, and database connections.
Defined Under Namespace
Classes: HealthMetrics
Class Method Summary collapse
-
.call ⇒ HealthMetrics
Call the get_system_health_counts_v01 SQL function.
Methods inherited from FunctionWrapper
connection, convert_array_bind, from_sql_function, #readonly?, single_from_sql_function
Class Method Details
.call ⇒ HealthMetrics
Call the get_system_health_counts_v01 SQL function
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/tasker/functions/function_based_system_health_counts.rb', line 55 def self.call sql = 'SELECT * FROM get_system_health_counts_v01()' result = connection.select_all(sql, 'SystemHealthCounts Load') if result.empty? # Return zero values if no data (shouldn't happen but defensive) HealthMetrics.new( total_tasks: 0, pending_tasks: 0, in_progress_tasks: 0, complete_tasks: 0, error_tasks: 0, cancelled_tasks: 0, total_steps: 0, pending_steps: 0, in_progress_steps: 0, complete_steps: 0, error_steps: 0, retryable_error_steps: 0, exhausted_retry_steps: 0, in_backoff_steps: 0, active_connections: 0, max_connections: 0 ) else # Convert the result to a structured HealthMetrics object row = result.first HealthMetrics.new( total_tasks: row['total_tasks'].to_i, pending_tasks: row['pending_tasks'].to_i, in_progress_tasks: row['in_progress_tasks'].to_i, complete_tasks: row['complete_tasks'].to_i, error_tasks: row['error_tasks'].to_i, cancelled_tasks: row['cancelled_tasks'].to_i, total_steps: row['total_steps'].to_i, pending_steps: row['pending_steps'].to_i, in_progress_steps: row['in_progress_steps'].to_i, complete_steps: row['complete_steps'].to_i, error_steps: row['error_steps'].to_i, retryable_error_steps: row['retryable_error_steps'].to_i, exhausted_retry_steps: row['exhausted_retry_steps'].to_i, in_backoff_steps: row['in_backoff_steps'].to_i, active_connections: row['active_connections'].to_i, max_connections: row['max_connections'].to_i ) end end |