BigW Consortium Gitlab

projects_controller.rb 1.06 KB
Newer Older
1
class Explore::ProjectsController < Explore::ApplicationController
2 3
  def index
    @projects = ProjectsFinder.new.execute(current_user)
4 5 6
    @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?
7
    @projects = @projects.non_archived
8 9
    @projects = @projects.search(params[:search]) if params[:search].present?
    @projects = @projects.sort(@sort = params[:sort])
10
    @projects = @projects.includes(:namespace).page(params[:page]).per(PER_PAGE)
11 12 13 14
  end

  def trending
    @trending_projects = TrendingProjectsFinder.new.execute(current_user)
15
    @trending_projects = @trending_projects.non_archived
16
    @trending_projects = @trending_projects.page(params[:page]).per(PER_PAGE)
17
  end
18 19 20

  def starred
    @starred_projects = ProjectsFinder.new.execute(current_user)
21
    @starred_projects = @starred_projects.reorder('star_count DESC')
22
    @starred_projects = @starred_projects.page(params[:page]).per(PER_PAGE)
23
  end
24
end