Commit 17021ea5f2d5baaf5d9601de9c27f55524d79240
1 parent
c0b20bb8
Exists in
master
and in
1 other branch
Mongo MapReduce is a real performance killer. Using query with indexes instead.
Showing
1 changed file
with
1 additions
and
9 deletions
Show diff stats
app/models/problem.rb
| ... | ... | @@ -2,14 +2,6 @@ |
| 2 | 2 | # reported as various Errs, but the user has grouped the |
| 3 | 3 | # Errs together as belonging to the same problem. |
| 4 | 4 | |
| 5 | -## Add methode nan? in Time because needed by #max(:created_at) | |
| 6 | -# | |
| 7 | -# Fix on Mongoid > 2.3.x with commit : | |
| 8 | -# https://github.com/mongoid/mongoid/commit/5481556e24480f0a1783f85d6b5b343b0cef7192 | |
| 9 | -class Time | |
| 10 | - def nan?; false ;end | |
| 11 | -end | |
| 12 | - | |
| 13 | 5 | class Problem |
| 14 | 6 | include Mongoid::Document |
| 15 | 7 | include Mongoid::Timestamps |
| ... | ... | @@ -132,7 +124,7 @@ class Problem |
| 132 | 124 | |
| 133 | 125 | def cache_notice_attributes(notice=nil) |
| 134 | 126 | notice ||= notices.first |
| 135 | - attrs = {:last_notice_at => notices.max(:created_at)} | |
| 127 | + attrs = {:last_notice_at => notices.order_by([:created_at, :asc]).last.try(:created_at)} | |
| 136 | 128 | attrs.merge!( |
| 137 | 129 | :message => notice.message, |
| 138 | 130 | :environment => notice.environment_name, | ... | ... |