summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Brandl <abrandl@gitlab.com>2018-02-22 11:12:28 +0100
committerAndreas Brandl <abrandl@gitlab.com>2018-02-26 13:10:46 +0100
commitdf55efda34dafcd85c20ff307ecb20ce1190741a (patch)
tree24cee48ded3e133e8948078ec0fe59022a37a93b
parentf330f6596094751ec03dbde4eb8389d0281acaae (diff)
downloadgitlab-ce-43304-simplify-filtering-non-human-users.tar.gz
Simplify filtering of non-human users (like ghosts).43304-simplify-filtering-non-human-users
Note that `ghost IS NOT TRUE` is equivalent to `ghost = 'f' OR ghost is null`: (true), (false), (NULL)) AS t (flag); flag | ?column? | ?column? ------+----------+---------- t | f | f f | t | t | t | t (3 rows) This makes it a little easier to create partial indexes for this (as only one condition is needed). Closes #43304.
-rw-r--r--app/models/user.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index f5eeba27572..0401a244566 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -431,7 +431,7 @@ class User < ActiveRecord::Base
end
def self.non_internal
- where(Hash[internal_attributes.zip([[false, nil]] * internal_attributes.size)])
+ where(internal_attributes.map { |attr| "#{attr} IS NOT TRUE" }.join(" AND "))
end
#