更改:疑修param为index以及新增统计标签下合并请求数量
This commit is contained in:
parent
edc00d28a7
commit
dc9ca7d0ca
|
@ -1,7 +1,7 @@
|
|||
class Api::V1::Issues::JournalsController < Api::V1::IssuesController
|
||||
class Api::V1::Issues::JournalsController < Api::V1::BaseController
|
||||
before_action :require_login, except: [:index, :children_journals]
|
||||
before_action :require_public_and_member_above, only: [:index, :create, :children_journals, :update, :destroy]
|
||||
before_action :load_issue, only: [:index, :create, :children_journals, :update, :destroy]
|
||||
before_action :require_public_and_member_above
|
||||
before_action :load_issue
|
||||
before_action :load_journal, only: [:children_journals, :update, :destroy]
|
||||
before_action :check_journal_operate_permission, only: [:update, :destroy]
|
||||
|
||||
|
@ -41,6 +41,13 @@ class Api::V1::Issues::JournalsController < Api::V1::IssuesController
|
|||
params.permit(:notes, :parent_id, :reply_id, :attachment_ids => [])
|
||||
end
|
||||
|
||||
def load_issue
|
||||
@issue = @project.issues.where(project_issues_index: params[:index]).where.not(id: params[:index]).take || Issue.find_by_id(params[:index])
|
||||
if @issue.blank?
|
||||
render_not_found("疑修不存在!")
|
||||
end
|
||||
end
|
||||
|
||||
def load_journal
|
||||
@journal = Journal.find_by_id(params[:id])
|
||||
return render_not_found("评论不存在!") unless @journal.present?
|
||||
|
|
|
@ -11,6 +11,7 @@ class Api::V1::Issues::MilestonesController < Api::V1::BaseController
|
|||
@closed_milestone_count = @milestones.closed.size
|
||||
@opening_milestone_count = @milestones.opening.size
|
||||
@milestones = params[:category] == "closed" ? @milestones.closed : @milestones.opening
|
||||
@milestones = milestones.order("#{sort_by} #{sort_direction}")
|
||||
if params[:only_name]
|
||||
@milestones = @milestones.select(:id, :name)
|
||||
@milestones = kaminary_select_paginate(@milestones)
|
||||
|
|
|
@ -57,10 +57,10 @@ class Api::V1::IssuesController < Api::V1::BaseController
|
|||
end
|
||||
end
|
||||
|
||||
protected
|
||||
private
|
||||
|
||||
def load_issue
|
||||
@issue = @project.issues.where(project_issues_index: params[:id]).where.not(id: params[:id]).take || Issue.find_by_id(params[:id])
|
||||
@issue = @project.issues.where(project_issues_index: params[:index]).where.not(id: params[:index]).take || Issue.find_by_id(params[:index])
|
||||
if @issue.blank?
|
||||
render_not_found("疑修不存在!")
|
||||
end
|
||||
|
@ -79,9 +79,7 @@ class Api::V1::IssuesController < Api::V1::BaseController
|
|||
|
||||
def check_issue_operate_permission
|
||||
return render_forbidden("您没有操作权限!") unless @project.member?(current_user) || current_user.admin? || @issue.user == current_user
|
||||
end
|
||||
|
||||
private
|
||||
end
|
||||
|
||||
def query_params
|
||||
params.permit(
|
||||
|
|
|
@ -15,5 +15,15 @@
|
|||
|
||||
class IssueTagsRelate < ApplicationRecord
|
||||
belongs_to :issue
|
||||
belongs_to :issue_tag, counter_cache: :issues_count
|
||||
belongs_to :issue_tag
|
||||
|
||||
after_create :increment_issue_tags_counter_cache
|
||||
|
||||
def increment_issue_tags_counter_cache
|
||||
if self.issue.issue_classify == "Issue"
|
||||
IssueTag.increment_counter :issues_count, issue_tag_id
|
||||
else
|
||||
IssueTag.increment_counter :pull_requests_count, issue_tag_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ class Api::V1::Issues::Milestones::DetailIssuesService < ApplicationService
|
|||
@author_id = params[:author_id]
|
||||
@assigner_id = params[:assigner_id]
|
||||
@issue_tag_ids = params[:issue_tag_ids].present? ? params[:issue_tag_ids].split(",") : []
|
||||
@sort_by = params[:sort_by].present? ? params[:sort_by] : 'updated_on'
|
||||
@sort_by = params[:sort_by].present? ? params[:sort_by] : 'issues.updated_on'
|
||||
@sort_direction = (params[:sort_direction].present? ? params[:sort_direction] : 'desc').downcase
|
||||
@current_user = current_user
|
||||
end
|
||||
|
|
|
@ -2,6 +2,7 @@ json.total_issues_count @total_issues_count
|
|||
json.opened_count @opened_issues_count
|
||||
json.closed_count @closed_issues_count
|
||||
json.total_count @issues.total_count
|
||||
json.has_created_issues @project.issues.size > 0
|
||||
json.issues @issues.each do |issue|
|
||||
json.partial! "simple_detail", locals: {issue: issue}
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
json.(tag,:id, :name, :description, :color)
|
||||
json.issues_count tag.issue_issues.size
|
||||
json.pull_requests_count tag.pull_request_issues.size
|
||||
json.issues_count tag.issues_count
|
||||
json.pull_requests_count tag.pull_requests_count
|
||||
json.project do
|
||||
if tag.project.present?
|
||||
json.partial! "api/v1/projects/simple_detail", project: tag.project
|
||||
|
|
|
@ -25,7 +25,7 @@ defaults format: :json do
|
|||
end
|
||||
end
|
||||
|
||||
resources :issues, except: [:new, :edit] do
|
||||
resources :issues, param: :index, except: [:new, :edit] do
|
||||
collection do
|
||||
patch :batch_update
|
||||
delete :batch_destroy
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddSomeColumnsToIssueUpgrade < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :issue_tags, :pull_requests_count, :integer, default: 0
|
||||
end
|
||||
end
|
|
@ -29,9 +29,13 @@ namespace :upgrade_issue_generate_data do
|
|||
puts "____________fix start________________"
|
||||
IssuePriority.init_data
|
||||
IssueStatus.init_data
|
||||
IssueTag.order(created_at: :desc).find_each do |it|
|
||||
it.update_column(:issues_count, it.issue_issues.size)
|
||||
it.update_column(:pull_requests_count, it.pull_request_issues.size)
|
||||
end
|
||||
IssueTag.where(user_id: nil).destroy_all
|
||||
count = 0
|
||||
Project.order(created_at: :desc).find_each do |project|
|
||||
Project.order(created_on: :desc).find_each do |project|
|
||||
count += 1
|
||||
IssueTag.init_data(project.id)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue