Class: AnalyticsOps::Portfolio

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

Overview

Read-only summary across every profile in one Analytics Ops configuration.

Defined Under Namespace

Classes: Collection, Entry, ProfileResult, Result

Instance Method Summary collapse

Constructor Details

#initialize(config:, store: ServiceAccount::Store.new, workspace_loader: nil, service_account_loader: nil, transport: :grpc, timeout: nil, logger: nil) ⇒ Portfolio

Returns a new instance of Portfolio.



73
74
75
76
77
78
79
80
81
82
# File 'lib/analytics_ops/portfolio.rb', line 73

def initialize(config:, store: ServiceAccount::Store.new, workspace_loader: nil,
               service_account_loader: nil, transport: :grpc, timeout: nil, logger: nil)
  @config = config
  @store = store
  @workspace_loader = workspace_loader || method(:load_workspace)
  @service_account_loader =  || ServiceAccount.method(:load)
  @transport = transport
  @timeout = timeout
  @logger = logger
end

Instance Method Details

#health(date_ranges: nil, concurrency: 4) ⇒ Collection

Parameters:

  • date_ranges: (Array[record], nil) (defaults to: nil)
  • concurrency: (Integer) (defaults to: 4)

Returns:



102
103
104
105
106
107
# File 'lib/analytics_ops/portfolio.rb', line 102

def health(date_ranges: nil, concurrency: 4)
  collect(kind: "health", name: "health", date_ranges:, concurrency:) do |target|
    result = date_ranges ? target.health(date_ranges:) : target.health
    result.to_h
  end
end

#overview(date_ranges: nil) ⇒ Result

Parameters:

  • date_ranges: (Array[record], nil) (defaults to: nil)

Returns:



84
85
86
87
88
89
90
91
92
93
# File 'lib/analytics_ops/portfolio.rb', line 84

def overview(date_ranges: nil)
  document = Configuration.load(@config)
  definition = Reports::Catalog.overview.first
  definition = definition.with_date_ranges(date_ranges) if date_ranges
  entries = document.profiles.sort.flat_map do |profile, desired_state|
    report = workspace(profile).report(definition)
    report_entries(profile, desired_state.property_id, report)
  end
  Result.new(entries:, date_ranges: definition.date_ranges)
end

#report(name, date_ranges: nil, concurrency: 4) ⇒ Object



95
96
97
98
99
100
# File 'lib/analytics_ops/portfolio.rb', line 95

def report(name, date_ranges: nil, concurrency: 4)
  collect(kind: "report", name: name.to_s, date_ranges:, concurrency:) do |target|
    result = date_ranges ? target.report(name, date_ranges:) : target.report(name)
    result.to_h
  end
end