mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-07-13 21:44:32 +08:00
@@ -0,0 +1,25 @@
|
||||
class SyncRepoUpdateTimeJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(*args)
|
||||
# Do something later
|
||||
Project.forge.find_each do |project|
|
||||
update_repo_time!(project)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def gitea_repo_updated_at(project)
|
||||
admin = User.where(admin: true).select(:id, :gitea_token, :gitea_uid).last
|
||||
|
||||
return nil if project.gpid.blank?
|
||||
|
||||
result = Gitea::Repository::GetByIdService.call(project.gpid, admin.gitea_token)
|
||||
|
||||
result[:status] === :success ? result[:body]['updated_at'] : nil
|
||||
end
|
||||
|
||||
def update_repo_time!(project)
|
||||
project.set_updated_on gitea_repo_updated_at(project)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user