ADD sync repo updated at time

(cherry picked from commit 8c6df359a5)
This commit is contained in:
Jasder
2021-01-08 18:07:48 +08:00
committed by moshenglv
parent f4dc82f7d5
commit 8c8d9f64c4
6 changed files with 54 additions and 12 deletions
+25
View File
@@ -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