Skip to content

Commit

Permalink
Return all results of project autocompletion
Browse files Browse the repository at this point in the history
Since we now limit the search results, we don't have to filter
subprojects of a matched project.
Before this change a search for 'hom' would return no result. Although
there are many projects of the form 'home:$login'.
Now it would return the first 50 projects that start with 'hom'.
  • Loading branch information
bgeuken committed Dec 18, 2018
1 parent a02d521 commit 2411d39
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/api/app/models/project.rb
Expand Up @@ -91,9 +91,7 @@ def autocomplete(search)
where.not('name rlike ?', ::Configuration.unlisted_projects_filter) if ::Configuration.unlisted_projects_filter.present?
}
scope :remote, -> { where('NOT ISNULL(projects.remoteurl)') }
scope :autocomplete, lambda { |search|
where('lower(name) like lower(?)', "#{search}%").where.not('lower(name) like lower(?)', "#{search}%:%")
}
scope :autocomplete, ->(search) { where('lower(name) like lower(?)', "#{search}%") }

# will return all projects with attribute 'OBS:ImageTemplates'
scope :local_image_templates, lambda {
Expand Down
2 changes: 1 addition & 1 deletion src/api/spec/controllers/webui/project_controller_spec.rb
Expand Up @@ -150,7 +150,7 @@
@json_response = JSON.parse(response.body)
end

it { expect(@json_response).not_to include(apache_subproject.name) }
it { expect(@json_response).to include(apache_subproject.name) }
end

context 'and searching for parent project' do
Expand Down

0 comments on commit 2411d39

Please sign in to comment.