mirror of
https://github.com/riwiwa/muzi.git
synced 2026-03-04 00:51:59 -08:00
fix now-playing status on listenbrainz endpoint and add config support
This commit is contained in:
14
db/db.go
14
db/db.go
@@ -5,6 +5,8 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"muzi/config"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
)
|
||||
@@ -25,17 +27,7 @@ func CreateAllTables() error {
|
||||
}
|
||||
|
||||
func GetDbUrl(dbName bool) string {
|
||||
host := os.Getenv("PGHOST")
|
||||
port := os.Getenv("PGPORT")
|
||||
user := os.Getenv("PGUSER")
|
||||
pass := os.Getenv("PGPASSWORD")
|
||||
|
||||
if dbName {
|
||||
return fmt.Sprintf("postgres://%s:%s@%s:%s/%s",
|
||||
user, pass, host, port, "muzi")
|
||||
} else {
|
||||
return fmt.Sprintf("postgres://%s:%s@%s:%s", user, pass, host, port)
|
||||
}
|
||||
return config.Get().Database.GetDbUrl(dbName)
|
||||
}
|
||||
|
||||
func CreateDB() error {
|
||||
|
||||
Reference in New Issue
Block a user