Class: Tasker::Functions::FunctionBasedAnalyticsMetrics
- Inherits:
-
FunctionWrapper
- Object
- FunctionWrapper
- Tasker::Functions::FunctionBasedAnalyticsMetrics
- Defined in:
- lib/tasker/functions/function_based_analytics_metrics.rb
Overview
Wrapper for the get_analytics_metrics_v01 SQL function
This function provides comprehensive analytics metrics for performance monitoring, including system overview, performance metrics, and duration calculations.
Defined Under Namespace
Classes: AnalyticsMetrics
Class Method Summary collapse
-
.call(since_timestamp = nil) ⇒ AnalyticsMetrics
Call the get_analytics_metrics_v01 SQL function.
Methods inherited from FunctionWrapper
connection, convert_array_bind, from_sql_function, #readonly?, single_from_sql_function
Class Method Details
.call(since_timestamp = nil) ⇒ AnalyticsMetrics
Call the get_analytics_metrics_v01 SQL function
53 54 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 92 93 94 95 96 97 98 99 100 |
# File 'lib/tasker/functions/function_based_analytics_metrics.rb', line 53 def self.call( = nil) if sql = 'SELECT * FROM get_analytics_metrics_v01($1)' result = connection.select_all(sql, 'AnalyticsMetrics Load', []) else sql = 'SELECT * FROM get_analytics_metrics_v01()' result = connection.select_all(sql, 'AnalyticsMetrics Load') end if result.empty? # Return zero values if no data (shouldn't happen but defensive) AnalyticsMetrics.new( active_tasks_count: 0, total_namespaces_count: 0, unique_task_types_count: 0, system_health_score: 1.0, task_throughput: 0, completion_count: 0, error_count: 0, completion_rate: 0.0, error_rate: 0.0, avg_task_duration: 0.0, avg_step_duration: 0.0, step_throughput: 0, analysis_period_start: ( || 1.hour.ago).to_s, calculated_at: Time.current.to_s ) else # Convert the result to a structured AnalyticsMetrics object row = result.first AnalyticsMetrics.new( active_tasks_count: row['active_tasks_count'].to_i, total_namespaces_count: row['total_namespaces_count'].to_i, unique_task_types_count: row['unique_task_types_count'].to_i, system_health_score: row['system_health_score'].to_f, task_throughput: row['task_throughput'].to_i, completion_count: row['completion_count'].to_i, error_count: row['error_count'].to_i, completion_rate: row['completion_rate'].to_f, error_rate: row['error_rate'].to_f, avg_task_duration: row['avg_task_duration'].to_f, avg_step_duration: row['avg_step_duration'].to_f, step_throughput: row['step_throughput'].to_i, analysis_period_start: row['analysis_period_start'].to_s, calculated_at: row['calculated_at'].to_s ) end end |