projects_controller.rb 1.14 KB
Newer Older
Douwe Maan's avatar
Douwe Maan committed
1
class Explore::ProjectsController < Explore::ApplicationController
2
  skip_before_action :authenticate_user!,
Ciro Santilli's avatar
Ciro Santilli committed
3
                     :reject_blocked
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
4
5
6

  def index
    @projects = ProjectsFinder.new.execute(current_user)
7
8
9
    @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?
10
    @projects = @projects.non_archived
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
11
12
    @projects = @projects.search(params[:search]) if params[:search].present?
    @projects = @projects.sort(@sort = params[:sort])
13
    @projects = @projects.includes(:namespace).page(params[:page]).per(PER_PAGE)
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
14
15
16
17
  end

  def trending
    @trending_projects = TrendingProjectsFinder.new.execute(current_user)
18
    @trending_projects = @trending_projects.non_archived
19
    @trending_projects = @trending_projects.page(params[:page]).per(PER_PAGE)
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
20
  end
21
22
23

  def starred
    @starred_projects = ProjectsFinder.new.execute(current_user)
24
    @starred_projects = @starred_projects.reorder('star_count DESC')
25
    @starred_projects = @starred_projects.page(params[:page]).per(PER_PAGE)
26
  end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
27
end