Commit 8543313bf5396afe3bdf5851a84c688eacc8156f
1 parent
68bfcd05
Exists in
master
and in
4 other branches
Few more filters for admin / projects
Showing
3 changed files
with
25 additions
and
1 deletions
Show diff stats
app/controllers/admin/projects_controller.rb
| ... | ... | @@ -5,6 +5,8 @@ class Admin::ProjectsController < AdminController |
| 5 | 5 | @projects = Project.scoped |
| 6 | 6 | @projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present? |
| 7 | 7 | @projects = @projects.where(public: true) if params[:public_only].present? |
| 8 | + @projects = @projects.joins(:events).where('events.action = ?', Event::Pushed) if params[:with_push].present? | |
| 9 | + @projects = @projects.abandoned if params[:abandoned].present? | |
| 8 | 10 | @projects = @projects.where(namespace_id: nil) if params[:namespace_id] == Namespace.global_id |
| 9 | 11 | @projects = @projects.search(params[:name]) if params[:name].present? |
| 10 | 12 | @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20) | ... | ... |
app/models/project.rb
| ... | ... | @@ -84,6 +84,14 @@ class Project < ActiveRecord::Base |
| 84 | 84 | scope :public, where(public: true) |
| 85 | 85 | |
| 86 | 86 | class << self |
| 87 | + def abandoned | |
| 88 | + project_ids = Event.select('max(created_at) as latest_date, project_id'). | |
| 89 | + group('project_id'). | |
| 90 | + having('latest_date < ?', 6.months.ago).map(&:project_id) | |
| 91 | + | |
| 92 | + where(id: project_ids) | |
| 93 | + end | |
| 94 | + | |
| 87 | 95 | def active |
| 88 | 96 | joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC") |
| 89 | 97 | end | ... | ... |
app/views/admin/projects/index.html.haml
| ... | ... | @@ -21,6 +21,20 @@ |
| 21 | 21 | = label_tag :public_only, 'Public Only', class: 'control-label' |
| 22 | 22 | .controls |
| 23 | 23 | = check_box_tag :public_only, 1, params[:public_only] |
| 24 | + .control-group | |
| 25 | + = label_tag :with_push, 'Not empty', class: 'control-label' | |
| 26 | + .controls | |
| 27 | + = check_box_tag :with_push, 1, params[:with_push] | |
| 28 | + | |
| 29 | + %span.light Projects with push events | |
| 30 | + .control-group | |
| 31 | + = label_tag :abandoned, 'Abandoned', class: 'control-label' | |
| 32 | + .controls | |
| 33 | + = check_box_tag :abandoned, 1, params[:abandoned] | |
| 34 | + | |
| 35 | + %span.light No activity over 6 month | |
| 36 | + | |
| 37 | + | |
| 24 | 38 | |
| 25 | 39 | .form-actions |
| 26 | 40 | = submit_tag "Search", class: "btn submit primary" |
| ... | ... | @@ -44,4 +58,4 @@ |
| 44 | 58 | %p.nothing_here_message 0 projects matches |
| 45 | 59 | - else |
| 46 | 60 | %li.bottom |
| 47 | - = paginate @projects, theme: "admin" | |
| 61 | + = paginate @projects, theme: "gitlab" | ... | ... |