Skip to content

Commit

Permalink
Merge pull request #209 from jeyrschabu/fix_project_search
Browse files Browse the repository at this point in the history
Fixing a bug where search returned everything even on no match
  • Loading branch information
jeyrschabu committed Mar 1, 2017
2 parents 5ae31d8 + 7b2e040 commit a8a3d0a
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,18 @@ public class ProjectsController {
}

Set<Project> filter(Collection<Project> projects, Map<String, String> attributes) {
attributes = attributes.collect { k,v -> [ k.toLowerCase(), v ] }.collectEntries()
attributes = attributes.collect {
k,v -> [ k.toLowerCase(), v ]
}.findAll { k, v -> v }.collectEntries()

Set<Project> items = new HashSet<>()

if (attributes.containsKey("applications")) {
List<String> applications = attributes.applications.split(",")
items = projects.findAll { project ->
project.config.applications?.find { app -> applications.any { app.toLowerCase().contains(it.toLowerCase()) } } ||
project.config.clusters?.find { cluster ->
cluster.applications?.collect { app -> applications.any { app.toLowerCase().contains(it.toLowerCase()) } }
cluster.applications?.find { app -> applications.any { app.toLowerCase().contains(it.toLowerCase()) } }
}
}
attributes.remove("applications")
Expand Down

0 comments on commit a8a3d0a

Please sign in to comment.