Skip to content

Commit

Permalink
fix: review from piyush
Browse files Browse the repository at this point in the history
  • Loading branch information
soneda-yuya committed Jan 10, 2025
1 parent 6924834 commit 8fa074a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions server/.env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# General
PORT=8080
REEARTH_DB=mongodb://localhost
REEARTH_DB_ACCOUNT=reearth # for account database
REEARTH_DB_VIS=reearth # for visualizer database
REEARTH_DB=mongodb://localhost # for reearth database url
REEARTH_DB_ACCOUNT=reearth_account # for reearth account database name
REEARTH_DB_VIS=reearth # for reearth visualizer database name
REEARTH_HOST=https://localhost:8080
REEARTH_HOST_WEB=https://localhost:3000
REEARTH_ASSETBASEURL=https://localhost:8080/assets
Expand Down
2 changes: 1 addition & 1 deletion server/internal/app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ type Config struct {
Dev bool `pp:",omitempty"`
DB string `default:"mongodb://localhost"`
DB_Account string `pp:",omitempty"`
DB_Vis string `pp:",omitempty"`
DB_Users []appx.NamedURI `pp:",omitempty"`
DB_Vis string `pp:",omitempty"`
GraphQL GraphQLConfig `pp:",omitempty"`
Published PublishedConfig `pp:",omitempty"`
GCPProject string `envconfig:"GOOGLE_CLOUD_PROJECT" pp:",omitempty"`
Expand Down
15 changes: 8 additions & 7 deletions server/internal/app/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (
"go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo"
)

const defaultDatabase = "reearth"
const defaultVisDatabase = "reearth"
const defaultAccountDatabase = "reearth_account"

func initReposAndGateways(ctx context.Context, conf *config.Config, debug bool) (*repo.Container, *gateway.Container, *accountrepo.Container, *accountgateway.Container) {
gateways := &gateway.Container{}
Expand All @@ -46,7 +47,7 @@ func initReposAndGateways(ctx context.Context, conf *config.Config, debug bool)
accountDatabase := conf.DB_Account
accountRepoCompat := false
if accountDatabase == "" {
accountDatabase = defaultDatabase
accountDatabase = defaultAccountDatabase
accountRepoCompat = true
}

Expand All @@ -66,13 +67,13 @@ func initReposAndGateways(ctx context.Context, conf *config.Config, debug bool)
log.Fatalf("Failed to init mongo: %+v\n", err)
}

// for reearth database
visualizerDatabase := conf.DB_Vis
if visualizerDatabase == "" {
visualizerDatabase = defaultDatabase
// for reearth visualizer database
visDatabase := conf.DB_Vis
if visDatabase == "" {
visDatabase = defaultVisDatabase
}

repos, err := mongorepo.NewWithExtensions(ctx, client.Database(visualizerDatabase), accountRepos, txAvailable, conf.Ext_Plugin)
repos, err := mongorepo.NewWithExtensions(ctx, client.Database(visDatabase), accountRepos, txAvailable, conf.Ext_Plugin)
if err != nil {
log.Fatalf("Failed to init mongo: %+v\n", err)
}
Expand Down

0 comments on commit 8fa074a

Please sign in to comment.