mirror of https://github.com/status-im/fathom.git
update readme with new db migration & vendor sync command
This commit is contained in:
parent
fbaa8d6932
commit
13216033b8
|
@ -14,9 +14,10 @@ This is nowhere near being usable, let alone stable. Please treat as a proof of
|
|||
For getting a development version of Ana up & running, please go through the following steps.
|
||||
|
||||
1. Rename `.env.example` to `.env` and set your database credentials.
|
||||
2. Install Go dependencies: `./do install_dependencies`
|
||||
3. Run the database migrations: `./do database_migrate up`
|
||||
3. Compile into binary: `./do bin`
|
||||
1. Create or migrate the database: `export $(cat .env | xargs) && $GOPATH/bin/migrate -url mysql://$ANA_DATABASE_USER:$ANA_DATABASE_PASSWORD@$ANA_DATABSE_HOST/$ANA_DATABASE_NAME -path ./db/migrations up`
|
||||
2. Make sure you have [govendor](https://github.com/kardianos/govendor) installed.
|
||||
2. Install Go dependencies: `govendor sync`
|
||||
3. Compile into binary: `make`
|
||||
4. Create your user account: `./ana -create_user -email="johndoe@email.com" -password="...."`
|
||||
5. Run default Gulp task to build static assets: `gulp`
|
||||
6. Start the webserver: `./ana -start_server -port=8080` & visit **localhost:8080** to access your analytics dashboard.
|
||||
|
|
|
@ -26,7 +26,7 @@ func Parse() {
|
|||
flag.BoolVar(&runCreateUserCommand, "create_user", false, "Create a new user")
|
||||
flag.BoolVar(&runDeleteUserCommand, "delete_user", false, "Deletes a user")
|
||||
flag.BoolVar(&runStartServerCommand, "start_server", true, "Start the API web server, listen on -port")
|
||||
flag.BoolVar(&runSeedDataCommand, "seed_data", false, "Seed the database -n times")
|
||||
flag.BoolVar(&runSeedDataCommand, "db_seed", false, "Seed the database -n times")
|
||||
flag.BoolVar(&runArchiveDataCommand, "archive_data", false, "Aggregates data into daily totals")
|
||||
flag.StringVar(&emailArg, "email", "", "Email address")
|
||||
flag.StringVar(&passwordArg, "password", "", "Password")
|
||||
|
|
|
@ -97,7 +97,7 @@ func calculatePointPercentages(points []Point, total int) []Point {
|
|||
for i, d := range points {
|
||||
points[i].PercentageValue = float64(d.Value) / float64(total) * 100
|
||||
}
|
||||
|
||||
|
||||
return points
|
||||
}
|
||||
|
||||
|
|
12
db/db.go
12
db/db.go
|
@ -10,9 +10,7 @@ import (
|
|||
|
||||
var Conn *sql.DB
|
||||
|
||||
// SetupDatabaseConnection opens up & returns a SQL connection
|
||||
func SetupDatabaseConnection() (*sql.DB, error) {
|
||||
var err error
|
||||
func getDSN() string {
|
||||
var dsn = fmt.Sprintf(
|
||||
"%s:%s@%s/%s",
|
||||
os.Getenv("ANA_DATABASE_USER"),
|
||||
|
@ -20,8 +18,14 @@ func SetupDatabaseConnection() (*sql.DB, error) {
|
|||
os.Getenv("ANA_DATABASE_HOST"),
|
||||
os.Getenv("ANA_DATABASE_NAME"),
|
||||
)
|
||||
return dsn
|
||||
}
|
||||
|
||||
Conn, err = sql.Open("mysql", dsn)
|
||||
// SetupDatabaseConnection opens up & returns a SQL connection
|
||||
func SetupDatabaseConnection() (*sql.DB, error) {
|
||||
var err error
|
||||
|
||||
Conn, err = sql.Open("mysql", getDSN())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue