debian-mirror-gitlab/app/controllers/explore/projects_controller.rb

62 lines
1.4 KiB
Ruby
Raw Normal View History

2015-09-11 14:41:01 +05:30
class Explore::ProjectsController < Explore::ApplicationController
2017-08-17 22:00:37 +05:30
include ParamsBackwardCompatibility
2018-03-17 18:26:18 +05:30
include RendersMemberAccess
2017-08-17 22:00:37 +05:30
before_action :set_non_archived_param
2016-06-02 11:05:42 +05:30
2014-09-02 18:07:02 +05:30
def index
2017-08-17 22:00:37 +05:30
params[:sort] ||= 'latest_activity_desc'
@sort = params[:sort]
2017-09-10 17:25:29 +05:30
@projects = load_projects
2016-04-02 18:10:28 +05:30
respond_to do |format|
format.html
format.json do
render json: {
html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
}
end
end
2014-09-02 18:07:02 +05:30
end
def trending
2017-08-17 22:00:37 +05:30
params[:trending] = true
@sort = params[:sort]
2017-09-10 17:25:29 +05:30
@projects = load_projects
2016-04-02 18:10:28 +05:30
respond_to do |format|
format.html
format.json do
render json: {
html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
}
end
end
2014-09-02 18:07:02 +05:30
end
def starred
2017-09-10 17:25:29 +05:30
@projects = load_projects.reorder('star_count DESC')
2016-04-02 18:10:28 +05:30
respond_to do |format|
format.html
format.json do
render json: {
html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
}
end
end
2014-09-02 18:07:02 +05:30
end
2017-08-17 22:00:37 +05:30
private
def load_projects
2018-03-17 18:26:18 +05:30
projects = ProjectsFinder.new(current_user: current_user, params: params)
.execute
.includes(:route, namespace: :route)
.page(params[:page])
.without_count
prepare_projects_for_rendering(projects)
2017-08-17 22:00:37 +05:30
end
2014-09-02 18:07:02 +05:30
end