Browse Source

新增:issue更新者字段

pull/347/head
yystopf 2 years ago
parent
commit
0c553203c1
5 changed files with 17 additions and 0 deletions
  1. +3
    -0
      app/models/issue.rb
  2. +1
    -0
      app/services/api/v1/issues/create_service.rb
  3. +1
    -0
      app/services/api/v1/issues/update_service.rb
  4. +7
    -0
      app/views/api/v1/issues/_detail.json.jbuilder
  5. +5
    -0
      db/migrate/20231114023928_add_changer_to_issues.rb

+ 3
- 0
app/models/issue.rb View File

@@ -39,12 +39,14 @@
# pm_issue_type :integer
# time_scale :decimal(10, 2) default("0.00")
# child_count :integer default("0")
# changer_id :integer
#
# Indexes
#
# index_issues_on_assigned_to_id (assigned_to_id)
# index_issues_on_author_id (author_id)
# index_issues_on_category_id (category_id)
# index_issues_on_changer_id (changer_id)
# index_issues_on_created_on (created_on)
# index_issues_on_fixed_version_id (fixed_version_id)
# index_issues_on_priority_id (priority_id)
@@ -90,6 +92,7 @@ class Issue < ApplicationRecord
has_many :attach_pull_requests, through: :pull_attached_issues, source: :pull_request
# PM 关联工作项目
has_many :pm_links, as: :linkable, dependent: :destroy
belongs_to :changer, class_name: 'User', foreign_key: :changer_id, optional: true

scope :issue_includes, ->{includes(:user)}
scope :issue_many_includes, ->{includes(journals: :user)}


+ 1
- 0
app/services/api/v1/issues/create_service.rb View File

@@ -67,6 +67,7 @@ class Api::V1::Issues::CreateService < ApplicationService
@created_issue.root_id = @root_id
@created_issue.time_scale = @time_scale
@created_issue.issue_tags_value = @issue_tags.order("id asc").pluck(:id).join(",") unless issue_tag_ids.blank?
@created_issue.changer_id = @current_user.id
@created_issue.save!

if Site.has_blockchain? && @project.use_blockchain


+ 1
- 0
app/services/api/v1/issues/update_service.rb View File

@@ -79,6 +79,7 @@ class Api::V1::Issues::UpdateService < ApplicationService
@updated_issue.time_scale = @time_scale unless @time_scale.nil?

@updated_issue.updated_on = Time.now
@updated_issue.changer_id = current_user.id
@updated_issue.save!

build_after_issue_journal_details if @updated_issue.previous_changes.present? # 操作记录


+ 7
- 0
app/views/api/v1/issues/_detail.json.jbuilder View File

@@ -33,6 +33,13 @@ json.author do
json.nil!
end
end
json.changer do
if issue.changer.present?
json.partial! "api/v1/users/simple_user", locals: {user: issue.changer}
else
json.nil!
end
end
json.assigners issue.show_assigners.each do |assigner|
json.partial! "api/v1/users/simple_user", locals: {user: assigner}
end


+ 5
- 0
db/migrate/20231114023928_add_changer_to_issues.rb View File

@@ -0,0 +1,5 @@
class AddChangerToIssues < ActiveRecord::Migration[5.2]
def change
add_reference :issues, :changer
end
end

Loading…
Cancel
Save