Commit 8543313b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Few more filters for admin / projects

parent 68bfcd05
...@@ -5,6 +5,8 @@ class Admin::ProjectsController < AdminController ...@@ -5,6 +5,8 @@ class Admin::ProjectsController < AdminController
@projects = Project.scoped @projects = Project.scoped
@projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present? @projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present?
@projects = @projects.where(public: true) if params[:public_only].present? @projects = @projects.where(public: true) if params[:public_only].present?
@projects = @projects.joins(:events).where('events.action = ?', Event::Pushed) if params[:with_push].present?
@projects = @projects.abandoned if params[:abandoned].present?
@projects = @projects.where(namespace_id: nil) if params[:namespace_id] == Namespace.global_id @projects = @projects.where(namespace_id: nil) if params[:namespace_id] == Namespace.global_id
@projects = @projects.search(params[:name]) if params[:name].present? @projects = @projects.search(params[:name]) if params[:name].present?
@projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20) @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20)
......
...@@ -84,6 +84,14 @@ class Project < ActiveRecord::Base ...@@ -84,6 +84,14 @@ class Project < ActiveRecord::Base
scope :public, where(public: true) scope :public, where(public: true)
class << self class << self
def abandoned
project_ids = Event.select('max(created_at) as latest_date, project_id').
group('project_id').
having('latest_date < ?', 6.months.ago).map(&:project_id)
where(id: project_ids)
end
def active def active
joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC") joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC")
end end
......
...@@ -21,6 +21,20 @@ ...@@ -21,6 +21,20 @@
= label_tag :public_only, 'Public Only', class: 'control-label' = label_tag :public_only, 'Public Only', class: 'control-label'
.controls .controls
= check_box_tag :public_only, 1, params[:public_only] = check_box_tag :public_only, 1, params[:public_only]
.control-group
= label_tag :with_push, 'Not empty', class: 'control-label'
.controls
= check_box_tag :with_push, 1, params[:with_push]
&nbsp;
%span.light Projects with push events
.control-group
= label_tag :abandoned, 'Abandoned', class: 'control-label'
.controls
= check_box_tag :abandoned, 1, params[:abandoned]
&nbsp;
%span.light No activity over 6 month
.form-actions .form-actions
= submit_tag "Search", class: "btn submit primary" = submit_tag "Search", class: "btn submit primary"
...@@ -44,4 +58,4 @@ ...@@ -44,4 +58,4 @@
%p.nothing_here_message 0 projects matches %p.nothing_here_message 0 projects matches
- else - else
%li.bottom %li.bottom
= paginate @projects, theme: "admin" = paginate @projects, theme: "gitlab"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment