debian-mirror-gitlab/app/controllers/dashboard_controller.rb

55 lines
1.3 KiB
Ruby
Raw Normal View History

2015-09-11 14:41:01 +05:30
class DashboardController < Dashboard::ApplicationController
before_action :load_projects
before_action :event_filter, only: :show
2014-09-02 18:07:02 +05:30
2015-09-11 14:41:01 +05:30
respond_to :html
2014-09-02 18:07:02 +05:30
def show
2015-04-26 12:48:37 +05:30
@projects = @projects.includes(:namespace)
2014-09-02 18:07:02 +05:30
@last_push = current_user.recent_push
respond_to do |format|
format.html
2015-04-26 12:48:37 +05:30
format.json do
load_events
pager_json("events/_events", @events.count)
end
2014-09-02 18:07:02 +05:30
2015-04-26 12:48:37 +05:30
format.atom do
load_events
render layout: false
end
end
2014-09-02 18:07:02 +05:30
end
def merge_requests
2015-04-26 12:48:37 +05:30
@merge_requests = get_merge_requests_collection
@merge_requests = @merge_requests.page(params[:page]).per(PER_PAGE)
2014-09-02 18:07:02 +05:30
@merge_requests = @merge_requests.preload(:author, :target_project)
end
def issues
2015-04-26 12:48:37 +05:30
@issues = get_issues_collection
@issues = @issues.page(params[:page]).per(PER_PAGE)
2014-09-02 18:07:02 +05:30
@issues = @issues.preload(:author, :project)
respond_to do |format|
format.html
format.atom { render layout: false }
end
end
protected
def load_projects
@projects = current_user.authorized_projects.sorted_by_activity.non_archived
end
2015-04-26 12:48:37 +05:30
def load_events
@events = Event.in_projects(current_user.authorized_projects.pluck(:id))
@events = @event_filter.apply_filter(@events).with_associations
@events = @events.limit(20).offset(params[:offset] || 0)
2014-09-02 18:07:02 +05:30
end
end