Sha256: 889b461d962ca00ef1346bed1f21f701f7a83b536f3b921d99d20d014c28a574
Contents?: true
Size: 1.19 KB
Versions: 9
Compression:
Stored size: 1.19 KB
Contents
module SnowmanIO class Check include Mongoid::Document include Mongoid::Timestamps STATUS_NEVER_RUNNED = "NEVER RUNNED" STATUS_OK = "OK" STATUS_FAILED = "FAILED" TEMPLATE_LAST_VALUE_LIMIT = "last_value_limit" TEMPLATE_PREV_DAY_DATAPOINTS_LIMIT = "prev_day_datapoints_limit" belongs_to :metric belongs_to :user # Each check should be one of available templates. Each metric is compatible only # with some templates. field :template, type: String # TEMPLATE_LAST_VALUE_LIMIT, TEMPLATE_PREV_DAY_DATAPOINTS_LIMIT field :cmp, type: String field :value, type: Float # COMMON field :triggered, type: Boolean, default: false field :last_run_at, type: DateTime field :last_status, type: String, default: STATUS_NEVER_RUNNED def as_json(options = {}) super(options).tap do |o| o["id"] = o.delete("_id").to_s o["metric_id"] = o["metric_id"].to_s o["user_id"] = o["user_id"].to_s end end def cmp_fn case cmp when "more" -> (a, b) { a ? a > b : false } when "less" -> (a, b) { a ? a < b : false } else raise "unreachable" end end end end
Version data entries
9 entries across 9 versions & 1 rubygems