Skip to content
Snippets Groups Projects

Add cron worker to automatically rollout zoekt exact code search to paid namespaces

Merged John Mason requested to merge jm-namespace-assignment-service into master
3 files
+ 57
48
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -55,13 +55,6 @@ def self.destroy_namespaces_with_expired_subscriptions!
end
end
def fetch_unassigned_projects(batch_size)
scope = namespace.all_projects.with_statistics
last_id = metadata[:last_processed_project_id]
scope = scope.where("projects.id > ?", last_id) if last_id
scope.order(repository_size: :desc).limit(batch_size)
end
def self.update_last_used_storage_bytes!
find_each(&:update_last_used_storage_bytes!)
end
@@ -76,6 +69,16 @@ def update_last_used_storage_bytes!
update_column(:metadata, metadata.merge(last_used_storage_bytes: size))
end
def fetch_unassigned_projects(batch_size)
# Fetch all projects in the namespace that are not associated with any zoekt index
namespace.all_projects
.with_statistics
.left_joins(:zoekt_repositories) # Join with zoekt_repository, allowing NULL matches
.where(zoekt_repositories: { id: nil }) # Filter for projects without a zoekt repository
.joins(:statistics).order(repository_size: :desc) # Prioritize by repository size
.limit(batch_size) # Limit the results to the batch size
end
private
def only_root_namespaces_can_be_indexed
Loading