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

This commit is contained in:
Jasder 2020-07-15 20:34:38 +08:00
commit 00c0fa0eb4
2 changed files with 28 additions and 30 deletions

View File

@ -7,7 +7,7 @@ class SyncForgeController < ApplicationController
sync_params = params[:sync_params]
project_user = User.where(login: sync_params[:owner_login])&.first
#以前已同步的项目,那么肯定存在仓库
SyncLog.sync_log("=================begin_to_sync_forge: project_identifier: #{sync_params[:identifier]}========")
user_projects = Project.where(user_id: project_user.id)
if user_projects.where(id: sync_params[:id], identifier: sync_params[:identifier]).present?
has_project = true
@ -24,8 +24,6 @@ class SyncForgeController < ApplicationController
if has_project
SyncLog.sync_log("=================begin_to_update_project========")
# project = user_projects.where(id: sync_params[:id]), identifier: sync_params[:identifier])&.first ||
check_sync_project(project, sync_params)
else #新建项目
SyncLog.sync_log("=================begin_to_create_new_project========")
@ -48,12 +46,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_log("=============new_project_create_failed, trustie_project_id==:#{params[:sync_params][:id]}")
SyncLog.sync_project_log("=============new_project_create_failed, trustie_project_id==:#{params[:sync_params][:id]}")
end
end
end
rescue Exception => e
SyncLog.sync_log("=============sync_has_errors:==#{e.message}, project_id==:#{params[:sync_params][:id]}")
SyncLog.sync_project_log("=============sync_has_errors:==#{e.message}, project_id==:#{params[:sync_params][:id]}")
end
def sync_users
@ -76,7 +74,6 @@ class SyncForgeController < ApplicationController
new_user = User.new(u[:user_params].merge(mail: u_mail))
username = new_user.login
password = "12345678"
if new_user.save!
SyncLog.sync_log("=================sync_to_user_success==#{new_user.login}")
@ -96,7 +93,7 @@ class SyncForgeController < ApplicationController
# SyncLog.sync_log("=================sync_to_user_failed,user_login==#{new_user.login}")
# end
# else
# SyncLog.sync_log("=============sync_to_user_failed,user_login====#{new_user.login}")
# 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}")
# end
# end
@ -112,9 +109,9 @@ class SyncForgeController < ApplicationController
def check_sync_project(project,sync_params)
begin
gitea_main = "https://www.trustie.net/"
if request.subdomain === 'testforgeplus'
gitea_main = "https://ucloudtest.trustie.net/"
end
# if request.subdomain === 'testforgeplus'
# gitea_main = "https://ucloudtest.trustie.net/"
# end
SyncLog.sync_log("----begin_to_check_sync_project----project_id:#{project.id}---------------")
change_project_score(project, sync_params[:project_score], sync_params[:repository]) if sync_params[:repository].present? #更新project_score
@ -140,9 +137,9 @@ class SyncForgeController < ApplicationController
}
gitea_main = "https://www.trustie.net/"
if request.subdomain === 'testforgeplus'
gitea_main = "https://ucloudtest.trustie.net/"
end
# if request.subdomain === 'testforgeplus'
# gitea_main = "https://ucloudtest.trustie.net/"
# end
SyncProjectsJob.perform_later(sync_projects_params, gitea_main)
SyncLog.sync_log("***8. end_to_sync_new_project---------------")
end
@ -195,8 +192,10 @@ class SyncForgeController < ApplicationController
begin
forge_issue_ids = project&.issues&.select(:id)&.pluck(:id)
sync_projects_params = {}
SyncLog.sync_log("***2--01. forge_issue_ids-#{forge_issue_ids.size.to_i}--------------")
if forge_issue_ids.size.to_i <= old_issues_params[:count].to_i
diff_issue_ids = old_issues_params[:ids] - forge_issue_ids
if diff_issue_ids.size == 0 #issue数量一样判断评论是否有增减
forge_journal_ids = Journal.select([:id, :journalized_id, :journalized_type]).where(journalized_id: forge_issue_ids).pluck(:id)
diff_journal_ids = old_issues_params[:journals][:ids] - forge_journal_ids
@ -217,7 +216,7 @@ class SyncForgeController < ApplicationController
}
end
end
SyncLog.sync_log("***2--02. sync_projects_params-#{sync_projects_params}--------------")
SyncProjectsJob.perform_later(sync_projects_params, gitea_main) if sync_projects_params.present?
SyncLog.sync_log("***2. end_to_syncissues---------------")
rescue Exception => e

View File

@ -112,7 +112,6 @@ class SyncProjectsJob < ApplicationJob
rescue => e
SyncLog.sync_log("=========***【#{target_type}】creat_had_erros:#{e}===================")
end
end
def create_journals(target_jsons, target_type,issue_id)