profjects filter with_push to project model

This commit is contained in:
Dmitriy Zaporozhets 2013-01-14 09:44:27 +02:00
parent 8543313bf5
commit f716c0a1dd
2 changed files with 5 additions and 1 deletions

View file

@ -5,7 +5,7 @@ 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.with_push 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?

View file

@ -92,6 +92,10 @@ class Project < ActiveRecord::Base
where(id: project_ids)
end
def with_push
includes(:events).where('events.action = ?', Event::Pushed)
end
def active
joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC")
end