diff options
author | James Lopez <james@jameslopez.es> | 2017-07-07 11:38:01 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-07-07 11:38:01 +0200 |
commit | 377244dd45773a5d587eaf3b75ba64702229e34e (patch) | |
tree | fc5327b7d466bc3b352999792edd10e7e88ff566 /app | |
parent | bfe5f2d19f5be3dd4e039fa5b2b0b6b27c748db9 (diff) | |
download | gitlab-ce-377244dd45773a5d587eaf3b75ba64702229e34e.tar.gz |
refactor filters
Diffstat (limited to 'app')
-rw-r--r-- | app/finders/issuable_finder.rb | 14 | ||||
-rw-r--r-- | app/finders/users_finder.rb | 14 |
2 files changed, 4 insertions, 24 deletions
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index 7bc2117f61e..39427d83669 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -19,6 +19,8 @@ # iids: integer[] # class IssuableFinder + include Gitlab::Database::CreatedAtFilter + NONE = '0'.freeze IRRELEVANT_PARAMS_FOR_CACHE_KEY = %i[utf8 sort page].freeze @@ -408,18 +410,6 @@ class IssuableFinder params[:non_archived].present? ? items.non_archived : items end - def by_created_at(items) - if params[:created_after].present? - items = items.where(items.klass.arel_table[:created_at].gteq(params[:created_after])) - end - - if params[:created_before].present? - items = items.where(items.klass.arel_table[:created_at].lteq(params[:created_before])) - end - - items - end - def current_user_related? params[:scope] == 'created-by-me' || params[:scope] == 'authored' || params[:scope] == 'assigned-to-me' end diff --git a/app/finders/users_finder.rb b/app/finders/users_finder.rb index ae031162892..c6bfc380c1c 100644 --- a/app/finders/users_finder.rb +++ b/app/finders/users_finder.rb @@ -14,6 +14,8 @@ # external: boolean # class UsersFinder + include Gitlab::Database::CreatedAtFilter + attr_accessor :current_user, :params def initialize(current_user, params = {}) @@ -72,16 +74,4 @@ class UsersFinder users.external end - - def by_created_at(users) - if params[:created_after].present? - users = users.where(users.klass.arel_table[:created_at].gteq(params[:created_after])) - end - - if params[:created_before].present? - users = users.where(users.klass.arel_table[:created_at].lteq(params[:created_before])) - end - - users - end end |