Commit 60a71b3a authored by Stan Hu's avatar Stan Hu

Merge branch 'da-repository-verification-find-outdated-projects' into 'master'

Geo - Calculate the checksum for outdated projects with less activity first

See merge request gitlab-org/gitlab-ee!5702
parents 8ba91334 96d65f18
......@@ -5,6 +5,7 @@ module Geo
.with_route
.joins(:repository_state)
.where(repository_outdated.or(wiki_outdated))
.order(last_repository_updated_at_asc)
.limit(batch_size)
end
......@@ -62,5 +63,9 @@ module Geo
def repository_never_verified
repository_state_table[:project_id].eq(nil)
end
def last_repository_updated_at_asc
Gitlab::Database.nulls_last_order('projects.last_repository_updated_at', 'ASC')
end
end
end
......@@ -43,6 +43,16 @@ describe Geo::RepositoryVerificationFinder, :postgresql do
expect(subject.find_outdated_projects(batch_size: 10)).to be_empty
end
it 'returns less active projects first' do
less_active_project = create(:project)
create(:repository_state, :repository_outdated, project: project)
create(:repository_state, :repository_outdated, project: less_active_project)
project.update_column(:last_repository_updated_at, 30.minutes.ago)
less_active_project.update_column(:last_repository_updated_at, 2.days.ago)
expect(subject.find_outdated_projects(batch_size: 10)).to eq [less_active_project, project]
end
end
describe '#find_unverified_projects' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment