change bugs
This commit is contained in:
parent
f6a9d1f54a
commit
7bd053a9b2
|
@ -41,12 +41,11 @@ class SyncProjectsJob < ApplicationJob
|
||||||
project.update(re[:target_params]) if re[:target_params].present?
|
project.update(re[:target_params]) if re[:target_params].present?
|
||||||
create_target(re[:issues_params], "Issue") if re[:issues_params].present?
|
create_target(re[:issues_params], "Issue") if re[:issues_params].present?
|
||||||
create_target(re[:member_params], "Member") if re[:member_params].present?
|
create_target(re[:member_params], "Member") if re[:member_params].present?
|
||||||
create_target(re[:versions_params], "Version") if re[:versions_params].present?
|
|
||||||
create_target(re[:watcher_params], "Watcher") if re[:watcher_params].present?
|
create_target(re[:watcher_params], "Watcher") if re[:watcher_params].present?
|
||||||
create_target(re[:praise_treads], "PraiseTread") if re[:praise_treads].present?
|
create_target(re[:praise_treads], "PraiseTread") if re[:praise_treads].present?
|
||||||
|
create_versions(project, re[:versions_params]) if re[:versions_params].present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def create_target(target_jsons, target_type)
|
def create_target(target_jsons, target_type)
|
||||||
SyncLog.sync_log("***【#{target_type}】. begin_to_create_target---------------")
|
SyncLog.sync_log("***【#{target_type}】. begin_to_create_target---------------")
|
||||||
return SyncLog.sync_log("*** no target_jsons") if target_jsons.blank?
|
return SyncLog.sync_log("*** no target_jsons") if target_jsons.blank?
|
||||||
|
@ -54,8 +53,7 @@ class SyncProjectsJob < ApplicationJob
|
||||||
if re[:target_params].present?
|
if re[:target_params].present?
|
||||||
SyncLog.sync_log("***user_login:#{re[:user_login]}----target_type:#{target_type}")
|
SyncLog.sync_log("***user_login:#{re[:user_login]}----target_type:#{target_type}")
|
||||||
u_id = User.select(:id, :login).where(login: re[:user_login]).pluck(:id).first
|
u_id = User.select(:id, :login).where(login: re[:user_login]).pluck(:id).first
|
||||||
new_target = target_type.constantize.new(re[:target_params].merge(user_id: u_id))
|
new_target = target_type.constantize.new(re[:target_params].delete(:id).merge(user_id: u_id))
|
||||||
|
|
||||||
if target_type == "Issue"
|
if target_type == "Issue"
|
||||||
assing_u_id = User.select(:id, :login).where(login: re[:assign_login]).pluck(:id).first
|
assing_u_id = User.select(:id, :login).where(login: re[:assign_login]).pluck(:id).first
|
||||||
new_target.assigned_to_id = assing_u_id
|
new_target.assigned_to_id = assing_u_id
|
||||||
|
@ -74,4 +72,23 @@ class SyncProjectsJob < ApplicationJob
|
||||||
end
|
end
|
||||||
SyncLog.sync_log("***111222. end_to_create_target---------------")
|
SyncLog.sync_log("***111222. end_to_create_target---------------")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_versions(project, target_jsons)
|
||||||
|
SyncLog.sync_log("***【Versions】. begin_to_create_verison---------------")
|
||||||
|
return SyncLog.sync_log("*** no target_jsons") if target_jsons.blank?
|
||||||
|
all_issues = project.issues.select(:id, :project_id, :fixed_version_id)
|
||||||
|
target_jsons.each do |re|
|
||||||
|
old_id = re[:target_params][:id]
|
||||||
|
if re[:target_params].present?
|
||||||
|
SyncLog.sync_log("***user_login:#{re[:user_login]}----target_type:#{target_type}")
|
||||||
|
u_id = User.select(:id, :login).where(login: re[:user_login]).pluck(:id).first
|
||||||
|
new_target = target_type.constantize.new(re[:target_params].delete(:id).merge(user_id: u_id))
|
||||||
|
if new_target.save!
|
||||||
|
all_issues&.where(fixed_version_id: old_id)&.update_all(fixed_version_id: new_target.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
SyncLog.sync_log("***111222. end_to_create_target---------------")
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
Loading…
Reference in New Issue