Skip to content
Browse files

Long Airbrake notice ids are long

  • Loading branch information...
1 parent d9f8f24 commit 4d808c4b65ea4b4bc4a056f25daa03a85a51429b @iain committed Jan 22, 2012
View
2 Gemfile
@@ -19,6 +19,8 @@ gem 'typhoeus'
gem 'nokogiri'
gem 'foreman'
+gem 'thin'
+
group :assets do
gem 'compass', '~> 0.12.alpha.4'
gem 'sass-rails'
View
7 Gemfile.lock
@@ -51,8 +51,10 @@ GEM
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
+ daemons (1.1.6)
diff-lcs (1.1.3)
erubis (2.7.0)
+ eventmachine (0.12.10)
execjs (1.2.13)
multi_json (~> 1.0)
factory_girl (2.4.0)
@@ -146,6 +148,10 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
term-ansicolor (1.0.7)
+ thin (1.3.1)
+ daemons (>= 1.0.9)
+ eventmachine (>= 0.12.6)
+ rack (>= 1.0.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
@@ -184,6 +190,7 @@ DEPENDENCIES
sass-rails
shoulda-matchers
simple_form!
+ thin
typhoeus
uglifier
will_paginate
View
15 app/models/airbrake/error.rb
@@ -2,15 +2,18 @@ class Airbrake::Error < ActiveRecord::Base
validates_presence_of :airbrake_project_id, :group_id, :notice_id
+ validates_uniqueness_of :notice_id
+
def self.import(data)
transaction do
- data[:notices].each do |notice|
- error = where(:notice_id => notice[:id]).first || new(:notice_id => notice[:id])
- error.resolved = data[:resolved]
+ Array(data[:notices]).each do |notice|
+ find_by = { :notice_id => notice[:id] }
+ error = where(find_by).first || new(find_by)
+ error.group_id = data[:id]
+ error.resolved = data[:resolved].to_s == "true"
error.airbrake_project_id = data[:project_id]
- error.error_message = data[:error_message]
- error.occurred_at = Time.parse(notice[:created_at])
- error.group_id = data[:id]
+ error.error_message = data[:error_message]
+ error.occurred_at = notice[:created_at]
error.save!
end
end
View
2 app/views/airbrake/errors/index.html.haml
@@ -5,11 +5,13 @@
%table.table.table-striped.errors
%thead
%tr
+ %th Resolved
%th Message
%th Date
%tbody
- @airbrake_errors.each do |error|
%tr
+ %td.resolved= error.resolved
%td.message
.ellipsis= error.error_message
%td.date= I18n.l error.occurred_at
View
9 db/migrate/20120122124619_change_notice_id_for_airbrake_errors.rb
@@ -0,0 +1,9 @@
+class ChangeNoticeIdForAirbrakeErrors < ActiveRecord::Migration
+ def up
+ change_column :airbrake_errors, :notice_id, :string, :length => 255
+ end
+
+ def down
+ change_column :airbrake_errors, :notice_id, :integer
+ end
+end
View
4 db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120118223847) do
+ActiveRecord::Schema.define(:version => 20120122124619) do
create_table "airbrake_deploys", :force => true do |t|
t.integer "airbrake_project_id"
@@ -30,7 +30,7 @@
create_table "airbrake_errors", :force => true do |t|
t.integer "airbrake_project_id", :null => false
t.integer "group_id", :null => false
- t.integer "notice_id", :null => false
+ t.string "notice_id", :default => "", :null => false
t.text "error_message"
t.boolean "resolved", :default => false
t.datetime "occurred_at"
View
2 script/airbrake_errors.rb
@@ -73,7 +73,7 @@ def get_errors(page = 1)
data = {
:id => id,
- :resolved => group.search("resolved").first.content == "true",
+ :resolved => group.search("resolved").first.content,
:project_id => group.search("project-id").first.content,
:error_message => group.search("error-message").first.content,
:notices => Nokogiri::XML(res.body).search("//notices/notice").map { |notice|

0 comments on commit 4d808c4

Please sign in to comment.
Something went wrong with that request. Please try again.