Class: AirbrakeAPI::Notice

Inherits:
Base
  • Object
show all
Defined in:
lib/airbrake-api/notice.rb

Constant Summary collapse

PER_PAGE =
30
PARALLEL_WORKERS =
10

Class Method Summary collapse

Class Method Details

.find(id, error_id, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/airbrake-api/notice.rb', line 8

def self.find(id, error_id, options={})
  setup

  hash = fetch(find_path(id, error_id), options)

  if hash.errors
    raise AirbrakeError.new(results.errors.error)
  end

  hash.notice
end

.find_all_by_error_id(error_id, notice_options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/airbrake-api/notice.rb', line 20

def self.find_all_by_error_id(error_id, notice_options = {})
  setup

  options = {}
  notices = []
  page = 1
  while !notice_options[:pages] || page <= notice_options[:pages]
    options[:page] = page
    hash = fetch(all_path(error_id), options)
    if hash.errors
      raise AirbrakeError.new(hash.errors.error)
    end

    batch = Parallel.map(hash.notices, :in_threads => PARALLEL_WORKERS) do |notice_stub|
      find(notice_stub.id, error_id)
    end
    yield batch if block_given?
    batch.each{|n| notices << n }

    break if batch.size < PER_PAGE
    page += 1
  end
  notices
end

.find_by_error_id(error_id, options = { 'page' => 1}) ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'lib/airbrake-api/notice.rb', line 45

def self.find_by_error_id(error_id, options={ 'page' => 1})
  setup

  hash = fetch(all_path(error_id), options)
  if hash.errors
    raise AirbrakeError.new(results.errors.error)
  end

  hash.notices
end