summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/database/created_at_filter.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/gitlab/database/created_at_filter.rb b/lib/gitlab/database/created_at_filter.rb
new file mode 100644
index 00000000000..3fa2770c65f
--- /dev/null
+++ b/lib/gitlab/database/created_at_filter.rb
@@ -0,0 +1,17 @@
+module Gitlab
+ module Database
+ module CreatedAtFilter
+ 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
+ end
+ end
+end