分页的部分修改
This commit is contained in:
parent
9073165cf3
commit
700537f4e2
|
@ -21,11 +21,8 @@ class IssuesController < ApplicationController
|
||||||
@assign_to_me_size = issues.where(assigned_to_id: current_user&.id).size
|
@assign_to_me_size = issues.where(assigned_to_id: current_user&.id).size
|
||||||
@my_published_size = issues.where(author_id: current_user&.id).size
|
@my_published_size = issues.where(author_id: current_user&.id).size
|
||||||
scopes = Issues::ListQueryService.call(issues,params)
|
scopes = Issues::ListQueryService.call(issues,params)
|
||||||
|
|
||||||
@page = params[:page]
|
|
||||||
@limit = params[:limit] || 15
|
|
||||||
@issues_size = scopes.size
|
@issues_size = scopes.size
|
||||||
@issues = scopes.page(@page).per(@limit)
|
@issues = paginate(scopes)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json
|
format.json
|
||||||
|
|
|
@ -19,11 +19,8 @@ class PullRequestsController < ApplicationController
|
||||||
@user_admin_or_member = current_user.present? && (current_user.admin || @project.member?(current_user))
|
@user_admin_or_member = current_user.present? && (current_user.admin || @project.member?(current_user))
|
||||||
|
|
||||||
scopes = Issues::ListQueryService.call(issues,params)
|
scopes = Issues::ListQueryService.call(issues,params)
|
||||||
|
|
||||||
@page = params[:page]
|
|
||||||
@limit = params[:limit] || 15
|
|
||||||
@issues_size = scopes.size
|
@issues_size = scopes.size
|
||||||
@issues = scopes.page(@page).per(@limit)
|
@issues = paginate(scopes)
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
|
@ -41,7 +41,7 @@ class Issues::ListQueryService < ApplicationService
|
||||||
|
|
||||||
order_type = params[:order_type] || "desc" #或者"asc"
|
order_type = params[:order_type] || "desc" #或者"asc"
|
||||||
order_name = params[:order_name] || "created_on" #或者"updated_on"
|
order_name = params[:order_name] || "created_on" #或者"updated_on"
|
||||||
issues.order("#{order_name} #{order_type}")
|
issues.reorder("#{order_name} #{order_type}")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue