Merge branch 'dev_trustie' of http://gitea.trustie.net/jasder/forgeplus into dev_trustie

This commit is contained in:
Jasder 2020-07-15 17:13:49 +08:00
commit 0a2423e912
3 changed files with 27 additions and 23 deletions

View File

@ -48,12 +48,12 @@ class SyncForgeController < ApplicationController
SyncRepositoryJob.perform_later(sync_params[:owner_login], sync_params[:identifier], sync_params[:repository], get_sudomain) if sync_params[:repository].present?
check_new_project(project, sync_params)
else
SyncLog.sync_project_log("=============new_project_create_failed, trustie_project_id==:#{params[:sync_params][:id]}")
SyncLog.sync_log("=============new_project_create_failed, trustie_project_id==:#{params[:sync_params][:id]}")
end
end
end
rescue Exception => e
SyncLog.sync_project_log("=============sync_has_errors:==#{e.message}, project_id==:#{params[:sync_params][:id]}")
SyncLog.sync_log("=============sync_has_errors:==#{e.message}, project_id==:#{params[:sync_params][:id]}")
end
def sync_users
@ -95,7 +95,7 @@ class SyncForgeController < ApplicationController
# SyncLog.sync_log("=================sync_to_user_failed,user_login==#{new_user.login}")
# end
# else
# SyncLog.sync_project_log("=============sync_to_user_failed,user_login====#{new_user.login}")
# SyncLog.sync_log("=============sync_to_user_failed,user_login====#{new_user.login}")
# SyncLog.sync_log("=================sync_to_user_failed,user_login====#{new_user.login}")
# end
# end

View File

@ -19,17 +19,17 @@ class SyncProjectsJob < ApplicationJob
if response.code == '200'
target_jsons = eval(response.body)
if sync_params[:type] == "Project"
SyncLog.sync_project_log("==========target_jsons: #{target_jsons}============")
SyncLog.sync_log("==========target_jsons: #{target_jsons}============")
update_new_project(target_jsons[:targets_params][0], sync_params[:new_project_id])
else
SyncLog.sync_project_log("========== #{sync_params[:type]}============")
SyncLog.sync_log("========== #{sync_params[:type]}============")
create_target(target_jsons[:targets_params], sync_params[:type].to_s)
end
else
SyncLog.sync_project_log("==========sync_project_to_forge_failed #{sync_params[:type]}============")
SyncLog.sync_log("==========sync_project_to_forge_failed #{sync_params[:type]}============")
end
rescue => e
SyncLog.sync_project_log("==========sync_project_to_forge_failed #{sync_params[:type]}============errors:#{e}")
SyncLog.sync_log("==========sync_project_to_forge_failed #{sync_params[:type]}============errors:#{e}")
end
end
@ -39,19 +39,19 @@ class SyncProjectsJob < ApplicationJob
SyncLog.sync_log("=========begin_to_update_project=project_id: #{project_id}============")
project = Project.find_by(id: project_id)
project.update(re[:target_params]) if re[:target_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[:watcher_params], "Watcher") if re[:watcher_params].present?
create_target(re[:praise_treads], "PraiseTread") if re[:praise_treads].present?
create_versions(project, re[:versions_params]) if re[:versions_params].present?
create_target(re[:issues_params], "Issue") if re[:issues_params].present?
end
def create_target(target_jsons, target_type)
begin
SyncLog.sync_project_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?
target_jsons.each_with_index do |re,index|
SyncLog.sync_project_log("***user_login:#{re[:user_login]}----target_type:#{target_type}-----#{index+1}")
SyncLog.sync_log("***user_login:#{re[:user_login]}----target_type:#{target_type}-----#{index+1}")
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
@ -59,9 +59,12 @@ class SyncProjectsJob < ApplicationJob
if target_type == "Issue"
is_exists = Issue.exists?(author_id: u_id, project_id: re[:target_params][:project_id], subject: re[:target_params][:subject])
unless is_exists
version_name = re[:target_params][:re_version]
version_id = Version.where(project_id: re[:target_params][:project_id], name: version_name)&.first&.id if version_name.present?
assing_u_id = User.select(:id, :login).where(login: re[:assign_login]).pluck(:id).first
new_target = target_type.constantize.new(re[:target_params].merge(author_id: u_id))
new_target.assigned_to_id = assing_u_id
new_target.fixed_version_id = version_id if version_id.present?
end
else
case target_type
@ -84,7 +87,7 @@ class SyncProjectsJob < ApplicationJob
end
if !is_exists && new_target.save!
SyncLog.sync_project_log("***【#{target_type}】. create_success---------------")
SyncLog.sync_log("***【#{target_type}】. create_success---------------")
if re[:journals].present?
create_journals(re[:journals], "Journal", new_target.id)
end
@ -101,13 +104,13 @@ class SyncProjectsJob < ApplicationJob
end
end
else
SyncLog.sync_project_log("***【#{target_type}】. create_failed---or has_exists---------------")
SyncLog.sync_log("***【#{target_type}】. create_failed---or has_exists---------------")
end
end
end
SyncLog.sync_project_log("***111222. end_to_create_target---------------")
SyncLog.sync_log("***111222. end_to_create_target---------------")
rescue => e
SyncLog.sync_project_log("=========***【#{target_type}】creat_had_erros:#{e}===================")
SyncLog.sync_log("=========***【#{target_type}】creat_had_erros:#{e}===================")
end
end
@ -122,7 +125,7 @@ class SyncProjectsJob < ApplicationJob
is_exists = Journal.exists?(user_id: u_id, journalized_id: re[:target_params][:journalized_id], created_on: re[:target_params][:created_on].to_s.to_time)
if is_exists
SyncLog.sync_project_log("***00000. Journal:#{re[:target_params][:id]}-is exists--------------")
SyncLog.sync_log("***00000. Journal:#{re[:target_params][:id]}-is exists--------------")
else
re[:target_params].delete(:id)
new_target = Journal.new(re[:target_params].merge(user_id: u_id))
@ -134,7 +137,7 @@ class SyncProjectsJob < ApplicationJob
end
end
else
SyncLog.sync_project_log("***111222. journal_create failed---------------")
SyncLog.sync_log("***111222. journal_create failed---------------")
end
end
end
@ -151,15 +154,16 @@ class SyncProjectsJob < ApplicationJob
u_id = User.select(:id, :login).where(login: re[:user_login]).pluck(:id).first
is_exists = Version.exists?(user_id: u_id, project_id: re[:target_params][:project_id], created_on: re[:target_params][:created_on].to_s.to_time)
if is_exists
SyncLog.sync_project_log("***00000. Version:#{re[:target_params][:id]}-is exists--------------")
SyncLog.sync_log("***00000. Version:#{re[:target_params][:id]}-is exists--------------")
else
re[:target_params].delete(:id)
new_target = Version.new(re[:target_params].merge(user_id: u_id))
if new_target.save!
all_issues = project.issues.select(:id, :project_id, :fixed_version_id)
all_issues&.where(fixed_version_id: old_id)&.update_all(fixed_version_id: new_target.id)
SyncLog.sync_log("***111222. Version_create success-#{new_target.id}--------------")
# all_issues = project.issues.select(:id, :project_id, :fixed_version_id)
# all_issues&.where(fixed_version_id: old_id)&.update_all(fixed_version_id: new_target.id)
else
SyncLog.sync_project_log("***111222. Version_create failed---------------")
SyncLog.sync_log("***111222. Version_create failed-#{old_id}--------------")
end
end
end

View File

@ -25,13 +25,13 @@ class SyncRepositoryJob < ApplicationJob
gitlab_branches.each do |branch|
shell5 = system("cd #{path}/#{image_repo_name} && git checkout #{branch} && git push --force --set-upstream origin #{branch}")
if !shell5
SyncLog.sync_project_log("=============force_push_erros==#{path}/#{image_repo_name}++branch:#{branch}")
SyncLog.sync_log("=============force_push_erros==#{path}/#{image_repo_name}++branch:#{branch}")
else
SyncLog.sync_project_log("=============force_push_success==#{path}/#{image_repo_name}++branch+++#{branch}")
SyncLog.sync_log("=============force_push_success==#{path}/#{image_repo_name}++branch+++#{branch}")
end
end
else
SyncLog.sync_project_log("=============check_clone_erros==#{path}/#{image_repo_name}")
SyncLog.sync_log("=============check_clone_erros==#{path}/#{image_repo_name}")
SyncLog.sync_log("++++++++++++++++++check_clone_erros++++++++++++++++++#{image_repo_name}")
end
SyncLog.sync_log("=================end to sync repository=====================#{image_repo_name}")