class HealthEvaluator
Scores 0-100 from what maintenance actually fixes.
Each component returns a value, its contribution and the operation that resolves it - the UI shows this, so the number stops being opaque.
A component without data is EXCLUDED and the total is normalised over the available weights. Missing data never becomes a penalty.
Constants
- DEFAULT_TARGET_FILE_SIZE
- HEALTHY_BOUNDARY
- REFERENCE_SNAPSHOT_WINDOW_DAYS
-
Steady-state horizon for the snapshot budget. Deliberately fixed (not the planβs retention_threshold) so raising retention cannot improve the score.
- WARNING_BOUNDARY
- WEIGHTS
Public Class Methods
# File app/services/health_evaluator.rb, line 30 def self.evaluate(extractor, plan: nil, now: Time.current, manifest_count: nil) new(extractor, plan: plan, now: now, manifest_count: manifest_count).call end
Convenience entry point that evaluates health from an extractor.
@param extractor [TableMetadataExtractor] the table metadata source @param plan [MaintenancePlan, nil] the maintenance plan for context @param now [Time] the reference clock @param manifest_count [Integer, nil] manifest count from Trino (post-maintenance) @return [Hash] the health score, status, components and coverage
# File app/services/health_evaluator.rb, line 40 def initialize(extractor, plan: nil, now: Time.current, manifest_count: nil) @extractor = extractor @plan = plan @now = now @manifest_count = manifest_count end
Creates the evaluator with the extractor, plan and clock.
@param extractor [TableMetadataExtractor] the table metadata source @param plan [MaintenancePlan, nil] the maintenance plan for context @param now [Time] the reference clock @param manifest_count [Integer, nil] manifest count from Trino (post-maintenance)
Public Instance Methods
Source
# File app/services/health_evaluator.rb, line 55 def call components = { fragmentation: fragmentation, snapshot_buildup: snapshot_buildup, delete_overhead: delete_overhead, manifest_buildup: manifest_buildup } available = components.reject { |_key, value| value.nil? } if available.empty? return { score: nil, status: :unknown, components: components, worst_component: nil, details: measured_values } end total_weight = available.keys.sum { |key| WEIGHTS[key] } earned = available.sum { |key, ratio| WEIGHTS[key] * ratio } score = ((earned / total_weight.to_f) * 100).round # The worst available component: the one whose ratio is lowest. This is # what actually needs attention β the composite can hide it. worst_key, worst_ratio = available.min_by { |_key, ratio| ratio } { score: score, status: status_for(score), components: components, coverage: (total_weight / WEIGHTS.values.sum.to_f * 100).round, worst_component: worst_key, worst_ratio: worst_ratio, details: measured_values } end
Computes the weighted health score and status from the available components.
The composite is diluted: a severe problem in one dimension is averaged against health in the others (a table 1000x off target can still score 60/warning). The result therefore also carries the worst component, so the UI can lead with it instead of the reassuring average.
@return [Hash] the score, status, components, coverage and worst_component