This commit is contained in:
yystopf 2023-02-24 09:04:29 +08:00
parent e53d6cd763
commit 267279df2d
2 changed files with 12 additions and 12 deletions

View File

@ -4,8 +4,8 @@ class Api::V1::Issues::IssueTagsController < Api::V1::BaseController
before_action :require_operate_above, only: [:create, :update, :destroy]
def index
@issue_tags = @project.issue_tags.order("#{order_by} #{order_direction}")
@issue_tags = @issue_tags.ransack(name_cont: params[:keyword]).result if params[:keyword].present?
@issue_tags = @project.issue_tags.reorder("#{sort_by} #{sort_direction}")
if params[:only_name]
@issue_tags = kaminary_select_paginate(@issue_tags.select(:id, :name, :color))
else
@ -43,16 +43,16 @@ class Api::V1::Issues::IssueTagsController < Api::V1::BaseController
private
def order_by
order_by = params.fetch(:order_by, "created_at")
order_by = IssueTag.column_names.include?(order_by) ? order_by : "created_at"
order_by
def sort_by
sort_by = params.fetch(:sort_by, "created_at")
sort_by = IssueTag.column_names.include?(sort_by) ? sort_by : "created_at"
sort_by
end
def order_direction
order_direction = params.fetch(:order_direction, "desc").downcase
order_direction = %w(desc asc).include?(order_direction) ? order_direction : "desc"
order_direction
def sort_direction
sort_direction = params.fetch(:sort_direction, "desc").downcase
sort_direction = %w(desc asc).include?(sort_direction) ? sort_direction : "desc"
sort_direction
end
def issue_tag_params

View File

@ -70,9 +70,9 @@ class Api::V1::Issues::ListService < ApplicationService
# keyword
issues = issues.ransack(subject_or_description_cont: keyword).result if keyword.present?
@total_issues_count = issues.size
@closed_issues_count = issues.closed.size
@opened_issues_count = issues.opened.size
@total_issues_count = issues.distinct.size
@closed_issues_count = issues.closed.distinct.size
@opened_issues_count = issues.opened.distinct.size
case category
when 'closed'