Skip to content

Commit

Permalink
Always create Cache object, so custom provenance can be created even …
Browse files Browse the repository at this point in the history
…enable_search is false (#1299)
  • Loading branch information
shifucun authored Nov 20, 2023
1 parent 0602e8f commit ef356e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 9 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/datacommonsorg/mixer/internal/server/resource"
"github.com/datacommonsorg/mixer/internal/sqldb"
"github.com/datacommonsorg/mixer/internal/sqldb/cloudsql"
"github.com/datacommonsorg/mixer/internal/sqldb/query"
"github.com/datacommonsorg/mixer/internal/sqldb/sqlite"
"github.com/datacommonsorg/mixer/internal/store"
"github.com/datacommonsorg/mixer/internal/store/bigtable"
Expand Down Expand Up @@ -224,7 +225,7 @@ func main() {
}
// Build the cache that includes stat var group info and stat var search
// Index.
var c *resource.Cache
c := &resource.Cache{}
if *useSearch {
c, err = cache.NewCache(
ctx, store,
Expand All @@ -237,6 +238,13 @@ func main() {
log.Fatalf("Failed to create cache: %v", err)
}
}
if store.SQLClient != nil {
customProv, err := query.GetProvenances(store.SQLClient)
if err != nil {
log.Fatalf("Failed to get provenance from SQL database: %s", err)
}
c.CustomProvenances = customProv
}

// Maps client
var mapsClient *maps.Client
Expand Down
8 changes: 0 additions & 8 deletions internal/server/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/datacommonsorg/mixer/internal/server/resource"
"github.com/datacommonsorg/mixer/internal/server/statvar"
"github.com/datacommonsorg/mixer/internal/sqldb/query"
"github.com/datacommonsorg/mixer/internal/store"
)

Expand Down Expand Up @@ -72,12 +71,5 @@ func NewCache(
result.SvgSearchIndex = statvar.BuildStatVarSearchIndex(rawSvg, parentSvgMap, blocklistSvg)
}
}
if store.SQLClient != nil {
customProv, err := query.GetProvenances(store.SQLClient)
if err != nil {
return nil, err
}
result.CustomProvenances = customProv
}
return result, nil
}

0 comments on commit ef356e4

Please sign in to comment.