Skip to content

Commit

Permalink
Merge pull request #344 from urosj/v4
Browse files Browse the repository at this point in the history
Support for windows and centos as "series"
  • Loading branch information
jujugui committed Apr 3, 2015
2 parents 9387141 + 7558903 commit 1a06fe4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 17 deletions.
28 changes: 20 additions & 8 deletions internal/charmstore/search.go
Expand Up @@ -34,10 +34,18 @@ const typeName = "entity"
// reverse order of LTS releases, followed by the latest
// non-LTS release, followed by everything else.
var seriesBoost = map[string]float64{
"bundle": 1.1255,
"trusty": 1.125,
"precise": 1.1125,
"utopic": 1.1,
"bundle": 1.1255,
"trusty": 1.125,
"precise": 1.1125,
"utopic": 1.1,
"win2012hvr2": 1.1,
"win2012hv": 1.1,
"win2012r2": 1.1,
"win2012": 1.1,
"win7": 1.1,
"win8": 1.1,
"win81": 1.1,
"centos7": 1.1,
}

// deprecatedSeries are series that should not show up in search
Expand Down Expand Up @@ -500,10 +508,14 @@ type SearchResult struct {
// elasticsearch query.
func queryFields(sp SearchParams) map[string]float64 {
fields := map[string]float64{
"URL.ngrams": 8,
"CharmMeta.Categories": 5,
"CharmMeta.Tags": 5,
"BundleData.Tags": 5,
"URL.ngrams": 8,
"CharmMeta.Categories": 5,
"CharmMeta.Tags": 5,
"BundleData.Tags": 5,
// TODO(uros): Series should be n-grams so that one
// can search for all "win*" charms/bundles even in
// without the series filter.
"Series": 5,
"CharmProvidedInterfaces": 3,
"CharmRequiredInterfaces": 3,
"CharmMeta.Description": 1,
Expand Down
26 changes: 17 additions & 9 deletions internal/router/router.go
Expand Up @@ -31,15 +31,23 @@ import (
// code)

var knownSeries = map[string]bool{
"bundle": true,
"oneiric": true,
"precise": true,
"quantal": true,
"raring": true,
"saucy": true,
"trusty": true,
"utopic": true,
"vivid": true,
"bundle": true,
"oneiric": true,
"precise": true,
"quantal": true,
"raring": true,
"saucy": true,
"trusty": true,
"utopic": true,
"vivid": true,
"win2012hvr2": true,
"win2012hv": true,
"win2012r2": true,
"win2012": true,
"win7": true,
"win8": true,
"win81": true,
"centos7": true,
}

// BulkIncludeHandler represents a metadata handler that can
Expand Down
13 changes: 13 additions & 0 deletions internal/router/router_test.go
Expand Up @@ -106,6 +106,19 @@ var routerGetTests = []struct {
Method: "GET",
CharmURL: "cs:precise/wordpress-34",
},
}, {
about: "windows id handler",
handlers: Handlers{
Id: map[string]IdHandler{
"foo": testIdHandler,
},
},
urlStr: "/win81/visualstudio-2012/foo",
expectStatus: http.StatusOK,
expectBody: idHandlerTestResp{
Method: "GET",
CharmURL: "cs:win81/visualstudio-2012",
},
}, {
about: "id handler with no series in id",
handlers: Handlers{
Expand Down

0 comments on commit 1a06fe4

Please sign in to comment.