diff --git a/app/jobs/sync_repo_metadata_job.rb b/app/jobs/sync_repo_metadata_job.rb index 6c5b769..3a5d0e1 100644 --- a/app/jobs/sync_repo_metadata_job.rb +++ b/app/jobs/sync_repo_metadata_job.rb @@ -11,9 +11,14 @@ class SyncRepoMetadataJob < ApplicationJob Rails.logger.info "[SyncRepoMetadataJob] Syncing metadata for #{repository.url}" begin - # Use any user who has mapped to this repository for API access - user = repository.users.joins(:project_repo_mappings).first - return unless user + user = repository.users + .joins(:project_repo_mappings) + .where.not(github_access_token: [ nil, "" ]) + .first + unless user + Rails.logger.warn "[SyncRepoMetadataJob] No user with GitHub token available for #{repository.url}" + return + end service = RepoHost::ServiceFactory.for_url(user, repository.url) metadata = service.fetch_repo_metadata diff --git a/config/initializers/good_job.rb b/config/initializers/good_job.rb index 92a3ef0..87b3778 100644 --- a/config/initializers/good_job.rb +++ b/config/initializers/good_job.rb @@ -123,12 +123,12 @@ Rails.application.configure do cron: "0 2 * * *", class: "ProcessAccountDeletionsJob", description: "nuke accounts after 30 days" + }, + sync_stale_repo_metadata: { + cron: "0 4 * * *", # Daily at 4 AM + class: "SyncStaleRepoMetadataJob", + description: "Refreshes repository metadata (stars, commit counts, etc.) for repositories with stale data." } - # sync_stale_repo_metadata: { - # cron: "0 4 * * *", # Daily at 4 AM - # class: "SyncStaleRepoMetadataJob", - # description: "Refreshes repository metadata (stars, commit counts, etc.) for repositories with stale data." - # }, # cleanup_old_leaderboards: { # cron: "0 3 * * *", # daily at 3 # class: "CleanupOldLeaderboardsJob",