ADD sync repo updated at time

This commit is contained in:
Jasder
2021-01-08 18:07:48 +08:00
parent 8f24f65820
commit 8c6df359a5
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