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
1 unresolved thread
Compare and Show latest version
7 files
+ 327
137
Compare changes
  • Side-by-side
  • Inline
Files
7
@@ -30,10 +30,6 @@ class EnabledNamespace < ApplicationRecord
raw_sql = 'min(zoekt_indices.state) = :state AND max(zoekt_indices.state) = :state'
joins(:indices).group(:id).having(raw_sql, state: Search::Zoekt::Index.states[:ready])
end
scope :pending_assignment, -> {
joins(:namespace).merge(Project.all_projects.with_statistics).distinct
.where("metadata->>'complete' IS NULL OR metadata->>'complete' = 'false'")
}
validates :metadata, json_schema: { filename: 'zoekt_enabled_namespaces_metadata' }
@@ -69,16 +65,6 @@ 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