dashboard_controller.rb 1.25 KB
Newer Older
gitlabhq's avatar
gitlabhq committed
1
class DashboardController < ApplicationController
2
  respond_to :html
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
3

4 5
  before_filter :event_filter, only: :index

gitlabhq's avatar
gitlabhq committed
6
  def index
7 8
    @groups = Group.where(id: current_user.projects.pluck(:group_id))
    @projects = current_user.projects_with_events
9
    @projects = @projects.page(params[:page]).per(30)
10

11 12 13 14
    @events = Event.in_projects(current_user.project_ids)
    @events = @event_filter.apply_filter(@events)
    @events = @events.limit(20).offset(params[:offset] || 0)

randx's avatar
randx committed
15
    @last_push = current_user.recent_push
16

randx's avatar
randx committed
17
    respond_to do |format|
randx's avatar
randx committed
18
      format.html
randx's avatar
randx committed
19
      format.js
20
      format.atom { render layout: false }
randx's avatar
randx committed
21
    end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
22 23
  end

24
  # Get authored or assigned open merge requests
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
25 26
  def merge_requests
    @projects = current_user.projects.all
27
    @merge_requests = current_user.cared_merge_requests.recent.page(params[:page]).per(20)
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
28 29
  end

30
  # Get only assigned issues
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
31 32 33
  def issues
    @projects = current_user.projects.all
    @user   = current_user
34
    @issues = current_user.assigned_issues.opened.recent.page(params[:page]).per(20)
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
35 36 37 38
    @issues = @issues.includes(:author, :project)

    respond_to do |format|
      format.html
39
      format.atom { render layout: false }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
40
    end
gitlabhq's avatar
gitlabhq committed
41
  end
42 43 44 45

  def event_filter
    @event_filter ||= EventFilter.new(params[:event_filter])
  end
gitlabhq's avatar
gitlabhq committed
46
end