This commit is contained in:
sylor_huang@126.com 2020-07-17 14:24:14 +08:00
parent 66d851f566
commit cdbe5396e2
2 changed files with 23 additions and 2 deletions

View File

@ -1,12 +1,19 @@
class CheckMirrorRake
# 运行示例: bundle exec rails runner "CheckMirrorRake.new.call()"
# 运行示例: 检查哪些项目的repo不存在bundle exec rails runner "CheckMirrorRake.new.call()"
def call
SyncLog.sync_log("=====begin to check mirror======")
empty_repo = []
all_projects = Project.select(:id,:identifier,:user_id, :gpid, :forked_count,:is_public).includes(:owner, :repository)
all_projects.each do |project|
SyncLog.sync_log("=====check_project_id:#{project.id}======")
CheckMirrorJob.perform_later(project)
# CheckMirrorJob.perform_later(project)
response = Gitea::Repository::Branches::ListService.new(project.owner, project.identifier).call
unless response.present?
empty_repo.push(project.id)
end
end
SyncLog.sync_log("=====completed_response:#{empty_repo}======")
end
end

View File

@ -0,0 +1,14 @@
class CreateMirrorRake
# 运行示例: 检查哪些项目的repo不存在bundle exec rails runner "CreateMirrorRake.new.call()"
def call
SyncLog.sync_log("=====begin to create mirror======")
empty_repo = []
all_projects = Project.select(:id,:identifier,:user_id, :gpid, :forked_count,:is_public).includes(:owner, :repository)
all_projects.each do |project|
SyncLog.sync_log("=====check_project_id:#{project.id}======")
CheckMirrorJob.perform_later(project)
end
SyncLog.sync_log("=====completed_response======")
end
end