projects_controller.rb 1.1 KB
Newer Older
1
class Dashboard::ProjectsController < Dashboard::ApplicationController
2
  before_action :event_filter
3

4 5
  def index
    @projects = current_user.authorized_projects.sorted_by_activity.non_archived
6
    @projects = @projects.sort(@sort = params[:sort])
7 8 9 10 11 12 13 14 15 16 17 18 19
    @projects = @projects.includes(:namespace)
    @last_push = current_user.recent_push

    respond_to do |format|
      format.html
      format.atom do
        event_filter
        load_events
        render layout: false
      end
    end
  end

20 21 22 23
  def starred
    @projects = current_user.starred_projects
    @projects = @projects.includes(:namespace, :forked_from_project, :tags)
    @projects = @projects.sort(@sort = params[:sort])
24
    @last_push = current_user.recent_push
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
    @groups = []

    respond_to do |format|
      format.html

      format.json do
        load_events
        pager_json("events/_events", @events.count)
      end
    end
  end

  private

  def load_events
40
    @events = Event.in_projects(@projects)
41 42 43 44
    @events = @event_filter.apply_filter(@events).with_associations
    @events = @events.limit(20).offset(params[:offset] || 0)
  end
end