2015-09-11 14:41:01 +05:30
|
|
|
class DashboardController < Dashboard::ApplicationController
|
2015-09-25 12:07:36 +05:30
|
|
|
before_action :event_filter, only: :activity
|
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 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
|
|
|
|
|
2015-09-25 12:07:36 +05:30
|
|
|
def activity
|
|
|
|
@last_push = current_user.recent_push
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2015-09-25 12:07:36 +05:30
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
|
|
|
|
format.json do
|
|
|
|
load_events
|
|
|
|
pager_json("events/_events", @events.count)
|
|
|
|
end
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2015-09-25 12:07:36 +05:30
|
|
|
protected
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
def load_events
|
2015-09-25 12:07:36 +05:30
|
|
|
project_ids =
|
|
|
|
if params[:filter] == "starred"
|
|
|
|
current_user.starred_projects
|
|
|
|
else
|
|
|
|
current_user.authorized_projects
|
|
|
|
end.pluck(:id)
|
|
|
|
|
|
|
|
@events = Event.in_projects(project_ids)
|
2015-04-26 12:48:37 +05:30
|
|
|
@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
|