summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-14 09:37:29 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-14 09:37:29 +0200
commit8543313bf5396afe3bdf5851a84c688eacc8156f (patch)
tree79abccc9e6ce690f93174a39d0c45cbd08bf1ccc
parent68bfcd0521020d9f0154ffe767aa1e327e93ca24 (diff)
downloadgitlab-ce-8543313bf5396afe3bdf5851a84c688eacc8156f.tar.gz
Few more filters for admin / projects
-rw-r--r--app/controllers/admin/projects_controller.rb2
-rw-r--r--app/models/project.rb8
-rw-r--r--app/views/admin/projects/index.html.haml16
3 files changed, 25 insertions, 1 deletions
diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb
index aa9e2f69a04..64aa6882b45 100644
--- a/app/controllers/admin/projects_controller.rb
+++ b/app/controllers/admin/projects_controller.rb
@@ -5,6 +5,8 @@ class Admin::ProjectsController < AdminController
@projects = Project.scoped
@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.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.search(params[:name]) if params[:name].present?
@projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20)
diff --git a/app/models/project.rb b/app/models/project.rb
index a826e04eac8..4d4a64753f1 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -84,6 +84,14 @@ class Project < ActiveRecord::Base
scope :public, where(public: true)
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
joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC")
end
diff --git a/app/views/admin/projects/index.html.haml b/app/views/admin/projects/index.html.haml
index 5a5c63ce6ad..a3c806bc913 100644
--- a/app/views/admin/projects/index.html.haml
+++ b/app/views/admin/projects/index.html.haml
@@ -21,6 +21,20 @@
= label_tag :public_only, 'Public Only', class: 'control-label'
.controls
= 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
= submit_tag "Search", class: "btn submit primary"
@@ -44,4 +58,4 @@
%p.nothing_here_message 0 projects matches
- else
%li.bottom
- = paginate @projects, theme: "admin"
+ = paginate @projects, theme: "gitlab"