Use !exists? instead of empty?

`exists?` issues a better SQL query than `empty?`
This commit is contained in:
Matt Rogers 2019-05-04 15:16:36 -05:00
parent 996395cc80
commit 11b9081064
No known key found for this signature in database
GPG key ID: 605D017C07EB4316

View file

@ -103,7 +103,7 @@ class Project < ApplicationRecord
def stalled?
# Stalled projects are active projects with no active next actions
return false if self.completed? || self.hidden?
return self.todos.deferred_or_blocked.empty? && self.todos.active.empty?
return !self.todos.deferred_or_blocked.exists? && !self.todos.active.exists?
end
def shortened_name(length=40)