BigW Consortium Gitlab

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

4 5
  def index
    @projects = ProjectsFinder.new.execute(current_user)
6 7 8
    @tags = @projects.tags_on(:tags)
    @projects = @projects.tagged_with(params[:tag]) if params[:tag].present?
    @projects = @projects.where(visibility_level: params[:visibility_level]) if params[:visibility_level].present?
9
    @projects = filter_projects(@projects)
10
    @projects = @projects.sort(@sort = params[:sort])
11
    @projects = @projects.includes(:namespace).page(params[:page])
12 13 14 15 16 17 18 19 20

    respond_to do |format|
      format.html
      format.json do
        render json: {
          html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
        }
      end
    end
21 22 23
  end

  def trending
24
    @projects = filter_projects(Project.trending)
25
    @projects = @projects.page(params[:page])
26 27 28 29 30 31 32 33 34

    respond_to do |format|
      format.html
      format.json do
        render json: {
          html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
        }
      end
    end
35
  end
36 37

  def starred
38
    @projects = ProjectsFinder.new.execute(current_user)
39
    @projects = filter_projects(@projects)
40
    @projects = @projects.reorder('star_count DESC')
41
    @projects = @projects.page(params[:page])
42 43 44 45 46 47 48 49 50

    respond_to do |format|
      format.html
      format.json do
        render json: {
          html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
        }
      end
    end
51
  end
52
end