BigW Consortium Gitlab

projects_controller.rb 1.54 KB
Newer Older
1
class Dashboard::ProjectsController < Dashboard::ApplicationController
2 3
  include FilterProjects

4
  before_action :event_filter
5

6
  def index
7 8
    @projects = current_user.authorized_projects.sorted_by_activity
    @projects = filter_projects(@projects)
9
    @projects = @projects.includes(:namespace)
10
    @projects = @projects.sort(@sort = params[:sort])
11
    @projects = @projects.page(params[:page])
12

13 14 15 16 17 18 19 20 21
    @last_push = current_user.recent_push

    respond_to do |format|
      format.html
      format.atom do
        event_filter
        load_events
        render layout: false
      end
22 23
      format.json do
        render json: {
Josh Frye committed
24
          html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
25 26
        }
      end
27 28 29
    end
  end

30
  def starred
31
    @projects = current_user.viewable_starred_projects.sorted_by_activity
32
    @projects = filter_projects(@projects)
33 34
    @projects = @projects.includes(:namespace, :forked_from_project, :tags)
    @projects = @projects.sort(@sort = params[:sort])
35
    @projects = @projects.page(params[:page])
Josh Frye committed
36

37
    @last_push = current_user.recent_push
38 39 40 41 42 43
    @groups = []

    respond_to do |format|
      format.html

      format.json do
Josh Frye committed
44
        render json: {
Josh Frye committed
45
          html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
Josh Frye committed
46
        }
47 48 49 50 51 52 53
      end
    end
  end

  private

  def load_events
54
    @events = Event.in_projects(@projects)
55 56 57 58
    @events = @event_filter.apply_filter(@events).with_associations
    @events = @events.limit(20).offset(params[:offset] || 0)
  end
end