use less string sql

pull/5130/head
Jens Ulferts 8 years ago
parent f36a4d3576
commit 1c6ed96679
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 16
      app/models/query.rb

@ -47,15 +47,19 @@ class Query < ActiveRecord::Base
validate :validate_work_package_filters
scope :visible, -> (to:) {
scope :visible, -> (to:) do
# User can see public queries and his own queries
where('is_public = ? OR user_id = ?',
true,
(to.logged? ? to.id : 0))
}
scope = where(is_public: true)
if to.logged?
scope.or(where(user_id: to.id))
else
scope
end
end
scope :global, -> {
where('project_id IS NULL')
where(project_id: nil)
}
# WARNING: sortable should not contain a column called id (except for the

Loading…
Cancel
Save