24 lines
944 B
Ruby
24 lines
944 B
Ruby
class TouchSyncJob < ApplicationJob
|
|
queue_as :default
|
|
|
|
def perform(touchable)
|
|
puts "aaaa"
|
|
case touchable.class.to_s
|
|
when 'SyncRepositories::Github' || 'SyncRepositories::Gitee'
|
|
Reposync::SyncRepoService.call(touchable.repo_name)
|
|
when 'SyncRepositoryBranch'
|
|
sync_repository = touchable.sync_repository
|
|
result = []
|
|
if sync_repository.sync_direction == 1
|
|
result = Reposync::SyncBranchService.call(sync_repository.repo_name, touchable.gitlink_branch_name, sync_repository.sync_direction)
|
|
else
|
|
result = Reposync::SyncBranchService.call(sync_repository.repo_name, touchable.external_branch_name, sync_repository.sync_direction)
|
|
end
|
|
if result.is_a?(Array) && result[0].to_i == 0
|
|
touchable.update_attributes!({sync_status: 1, sync_time: Time.now})
|
|
else
|
|
touchable.update_attributes!({sync_status: 2, sync_time: Time.now})
|
|
end
|
|
end
|
|
end
|
|
end |