Class: AnalyticsOps::Health::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/analytics_ops/health.rb,
sig/analytics_ops.rbs

Overview

Immutable health summary and findings for one profile.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(profile:, property_id:, date_ranges:, findings:, summary:) ⇒ Result

Returns a new instance of Result.



38
39
40
41
42
43
44
45
# File 'lib/analytics_ops/health.rb', line 38

def initialize(profile:, property_id:, date_ranges:, findings:, summary:)
  @profile = Canonical.immutable(profile)
  @property_id = Canonical.immutable(property_id)
  @date_ranges = Canonical.immutable(date_ranges)
  @findings = findings.dup.freeze
  @summary = Canonical.immutable(summary)
  freeze
end

Instance Attribute Details

#date_rangesArray[record] (readonly)

Returns the value of attribute date_ranges.

Returns:

  • (Array[record])


36
37
38
# File 'lib/analytics_ops/health.rb', line 36

def date_ranges
  @date_ranges
end

#findingsArray[Finding] (readonly)

Returns the value of attribute findings.

Returns:



36
37
38
# File 'lib/analytics_ops/health.rb', line 36

def findings
  @findings
end

#profileString (readonly)

Returns the value of attribute profile.

Returns:

  • (String)


36
37
38
# File 'lib/analytics_ops/health.rb', line 36

def profile
  @profile
end

#property_idString (readonly)

Returns the value of attribute property_id.

Returns:

  • (String)


36
37
38
# File 'lib/analytics_ops/health.rb', line 36

def property_id
  @property_id
end

#summaryrecord (readonly)

Returns the value of attribute summary.

Returns:

  • (record)


36
37
38
# File 'lib/analytics_ops/health.rb', line 36

def summary
  @summary
end

Instance Method Details

#healthy?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/analytics_ops/health.rb', line 47

def healthy?
  findings.none? { |finding| %w[warning error].include?(finding.severity) }
end

#to_hrecord

Returns:

  • (record)


51
52
53
54
55
56
57
58
59
60
# File 'lib/analytics_ops/health.rb', line 51

def to_h
  {
    "healthy" => healthy?,
    "profile" => profile,
    "property_id" => property_id,
    "date_ranges" => date_ranges,
    "summary" => summary,
    "findings" => findings.map(&:to_h)
  }
end