Class: SentrySummary::Aggregator

Inherits:
Object
  • Object
show all
Defined in:
lib/sentry-summary/aggregator.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Aggregator

Returns a new instance of Aggregator.



5
6
7
# File 'lib/sentry-summary/aggregator.rb', line 5

def initialize(client)
  @client = client
end

Instance Method Details

#events_by_route(since = "24 hours ago") ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sentry-summary/aggregator.rb', line 9

def events_by_route(since = "24 hours ago")
  issues = client.issues("api", since)

  issues.each_with_object({}) do |issue, hash|
    events = client.events(issue.id)

    events.each do |event|
      hash[event.route] ||= {}

      closest_title = closest_title(hash[event.route].keys, event.[:value])
      hash[event.route][closest_title] = (hash[event.route][closest_title] || 0) + 1
    end

    hash
  end
end

#events_by_type(since = "24 hours ago") ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/sentry-summary/aggregator.rb', line 26

def events_by_type(since = "24 hours ago")
  issues = client.issues("api", since)

  issues.each_with_object({}) do |issue, hash|
    events = client.events(issue.id)

    events.each do |event|
      type = event.[:value]
      type = closest_title(hash.keys, type)
      hash[type] ||= {}

      hash[type][event.route] = (hash[type][event.route] || 0) + 1
    end

    hash
  end
end