mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-02 19:30:48 +08:00
FIX actioncable job
This commit is contained in:
29
app/jobs/broadcast_mirror_repo_msg_job.rb
Normal file
29
app/jobs/broadcast_mirror_repo_msg_job.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
class BroadcastMirrorRepoMsgJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(repo_id)
|
||||
puts "############ BroadcastMirrorRepoMsgJob start ############ #{repo_id}"
|
||||
repo = Repository.find_by(id: repo_id)
|
||||
return if repo.blank?
|
||||
|
||||
project = repo.project
|
||||
|
||||
json_data = {
|
||||
mirror_status: repo.mirror_status,
|
||||
mirror_num: repo.mirror_num,
|
||||
mirror_url: repo.mirror_url,
|
||||
first_sync: repo.first_sync?,
|
||||
identifier: repo.identifier,
|
||||
name: project.name,
|
||||
id: project.id,
|
||||
type: project.numerical_for_project_type
|
||||
}
|
||||
puts "############ broadcast start.......... "
|
||||
puts "############ broadcast channel_name: channel_room_#{project.id}"
|
||||
puts "############ broadcast project data: #{json_data} "
|
||||
|
||||
cable_result = ActionCable.server.broadcast "channel_room_#{project.id}", project: json_data
|
||||
|
||||
puts "############ broadcast result: #{cable_result == 1 ? 'successed' : 'failed'} "
|
||||
end
|
||||
end
|
||||
@@ -10,24 +10,8 @@ class MigrateRemoteRepositoryJob < ApplicationJob
|
||||
gitea_repository = Gitea::Repository::MigrateService.new(token, params).call
|
||||
if gitea_repository
|
||||
repo&.project&.update_columns(gpid: gitea_repository["id"])
|
||||
repo&.mirror&.update_columns(status: Mirror.statuses[:succeeded])
|
||||
|
||||
project = repo.project
|
||||
|
||||
json_data = {
|
||||
mirror_status: repo.mirror_status,
|
||||
mirror_num: repo.mirror_num,
|
||||
mirror_url: repo.mirror_url,
|
||||
first_sync: repo.first_sync?,
|
||||
identifier: repo.identifier,
|
||||
name: project.name,
|
||||
id: project.id,
|
||||
type: project.numerical_for_project_type
|
||||
}
|
||||
puts "############ broadcast start.......... ############"
|
||||
cable_result = ActionCable.server.broadcast "channel_room_#{repo.identifier}", project: json_data
|
||||
|
||||
puts "############ room_channel_#{repo.identifier} result : #{cable_result}"
|
||||
repo&.mirror&.succeeded!
|
||||
puts "############ mirror status: #{repo.mirror.status} ############"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user