summaryrefslogtreecommitdiff
path: root/app/finders/projects_finder.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/finders/projects_finder.rb')
-rw-r--r--app/finders/projects_finder.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/finders/projects_finder.rb b/app/finders/projects_finder.rb
index 961694bd91f..2c3611875a2 100644
--- a/app/finders/projects_finder.rb
+++ b/app/finders/projects_finder.rb
@@ -21,6 +21,8 @@
# non_archived: boolean
# archived: 'only' or boolean
# min_access_level: integer
+# last_activity_after: datetime
+# last_activity_before: datetime
#
class ProjectsFinder < UnionFinder
include CustomAttributesFilter
@@ -73,6 +75,8 @@ class ProjectsFinder < UnionFinder
collection = by_archived(collection)
collection = by_custom_attributes(collection)
collection = by_deleted_status(collection)
+ collection = by_last_activity_after(collection)
+ collection = by_last_activity_before(collection)
collection
end
@@ -179,6 +183,22 @@ class ProjectsFinder < UnionFinder
params[:without_deleted].present? ? items.without_deleted : items
end
+ def by_last_activity_after(items)
+ if params[:last_activity_after].present?
+ items.where("last_activity_at > ?", params[:last_activity_after]) # rubocop: disable CodeReuse/ActiveRecord
+ else
+ items
+ end
+ end
+
+ def by_last_activity_before(items)
+ if params[:last_activity_before].present?
+ items.where("last_activity_at < ?", params[:last_activity_before]) # rubocop: disable CodeReuse/ActiveRecord
+ else
+ items
+ end
+ end
+
def sort(items)
params[:sort].present? ? items.sort_by_attribute(params[:sort]) : items.projects_order_id_desc
end