Sha256: c2c82c3cd487b15f5f811ad6568bb24a4fa9ddfd806f0934510feba2eb902dff

Contents?: true

Size: 921 Bytes

Versions: 1

Compression:

Stored size: 921 Bytes

Contents

module Aeternitas
  module WebUi
    module PollablesIndexStatistics
      def self.available_pollables
        Aeternitas::PollableMetaData.distinct(:pollable_class).pluck(:pollable_class).map(&:constantize)
      end

      def self.failure_ratio(pollable)
        Aeternitas::Metrics.failure_ratio(
            pollable,
            from: 24.hours.ago,
            to: Time.now,
            resolution: :hour
        ).avg.round(2)
      end

      def self.guard_locked_ratio(pollable)
        Aeternitas::Metrics.guard_locked_ratio(
            pollable,
            from: 24.hours.ago,
            to: Time.now,
            resolution: :hour
        ).avg.round(2)
      end

      def self.polls(pollable)
        Aeternitas::Metrics.polls(
            pollable,
            from: 24.hours.ago,
            to: Time.now,
            resolution: :hour
        ).map { |v| v[:count] }.sum
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aeternitas_web_ui-0.1.0 lib/aeternitas/web_ui/pollables_index_statistics.rb