Commit f716c0a1dd175527e688709cbbd71c121a43586e
1 parent
8543313b
Exists in
master
and in
4 other branches
profjects filter with_push to project model
Showing
2 changed files
with
5 additions
and
1 deletions
Show diff stats
app/controllers/admin/projects_controller.rb
| ... | ... | @@ -5,7 +5,7 @@ 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? | |
| 8 | + @projects = @projects.with_push if params[:with_push].present? | |
| 9 | 9 | @projects = @projects.abandoned if params[:abandoned].present? |
| 10 | 10 | @projects = @projects.where(namespace_id: nil) if params[:namespace_id] == Namespace.global_id |
| 11 | 11 | @projects = @projects.search(params[:name]) if params[:name].present? | ... | ... |
app/models/project.rb
| ... | ... | @@ -92,6 +92,10 @@ class Project < ActiveRecord::Base |
| 92 | 92 | where(id: project_ids) |
| 93 | 93 | end |
| 94 | 94 | |
| 95 | + def with_push | |
| 96 | + includes(:events).where('events.action = ?', Event::Pushed) | |
| 97 | + end | |
| 98 | + | |
| 95 | 99 | def active |
| 96 | 100 | joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC") |
| 97 | 101 | end | ... | ... |