lib/bug_hunter/models.rb in bug_hunter-0.0.5 vs lib/bug_hunter/models.rb in bug_hunter-0.0.6

- old
+ new

@@ -47,11 +47,11 @@ def self.minimal without(:comments, :request_env, :backtrace) end def similar_errors - self.class.where(:message => unique_error_selector[:message], :_id.ne => self.id) + self.class.where(:message => partial_message, :_id.ne => self.id) end def add_comment(from, message, ip) comment = {:from => from, :message => message, @@ -79,23 +79,36 @@ BugHunter::Project.collection.update({:_id => BugHunter::Project.instance.id}, {:$inc => {:errors_resolved_count => -1}}) end def unique_error_selector - msg = self[:message] - if msg.match(/#<.+>/) - msg = /^#{Regexp.escape($`)}/ - end - { :resolved => false, - :message => msg, + :message => partial_message, :file => self.file, :line => self.line, :method => self.method } end + def partial_message(regex = true) + msg = self[:message] + if msg.match(/#<.+>/) && $`.length > 10 + if regex + msg = /^#{Regexp.escape($`)}/ + else + msg = $` + end + elsif msg.match(/\{.+\}/) && $`.length > 10 + if regex + msg = /^#{Regexp.escape($`)}/ + else + msg = $` + end + end + + msg + end def self.build_from(env, exception) doc = self.new doc[:message] = exception.message doc[:backtrace] = exception.backtrace