Class: Hoptoad::Notice
Constant Summary collapse
- PER_PAGE =
30
- PARALLEL_WORKERS =
10
Class Method Summary collapse
- .find(id, error_id, options = {}) ⇒ Object
- .find_all_by_error_id(error_id, notice_options = {}) ⇒ Object
- .find_by_error_id(error_id, options = { 'page' => 1}) ⇒ Object
Class Method Details
.find(id, error_id, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/hoptoad-api/notice.rb', line 8 def self.find(id, error_id, ={}) setup hash = fetch(find_path(id, error_id), ) if hash.errors raise HoptoadError.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/hoptoad-api/notice.rb', line 20 def self.find_all_by_error_id(error_id, = {}) setup = {} notices = [] page = 1 while ![:pages] || page <= [:pages] [:page] = page hash = fetch(all_path(error_id), ) if hash.errors raise HoptoadError.new(results.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/hoptoad-api/notice.rb', line 45 def self.find_by_error_id(error_id, ={ 'page' => 1}) setup hash = fetch(all_path(error_id), ) if hash.errors raise HoptoadError.new(results.errors.error) end hash.notices end |