Skip to content

Commit

Permalink
chore(config): switch to yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed Dec 10, 2024
1 parent b8f4639 commit 0696f11
Show file tree
Hide file tree
Showing 39 changed files with 392 additions and 210 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Displays the cammie chat along with some other statistics.
- `APP_ENV`. Available options are:
- `development`
- `production`
- `SONG_SPOTIFY_CLIENT_ID`
- `SONG_SPOTIFY_CLIENT_SECRET`
2. Configure the appropriate settings in the corresponding configuration file located in the [config directory](./config)
- `BACKEND_SONG_SPOTIFY_CLIENT_ID`
- `BACKEND_SONG_SPOTIFY_CLIENT_SECRET`
2. Configure the appropriate settings in the corresponding configuration file located in the [config directory](./config). you can either set them as environment variables or inside the configuration file.

## DB

Expand Down
12 changes: 6 additions & 6 deletions cmd/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ func main() {
zap.S().Fatal("DB: Fatal error\n", err)
}

// // Tap
// _, _ = cmd.Tap(db)
// Tap
_, _ = cmd.Tap(db)

// // Zess
// _, _, _ = cmd.Zess(db)
// Zess
_, _, _ = cmd.Zess(db)

// // Gamification
// _, _ = cmd.Gamification(db)
// Gamification
_, _ = cmd.Gamification(db)

// Event
_, _ = cmd.Event(db)
Expand Down
78 changes: 0 additions & 78 deletions config/development.toml

This file was deleted.

113 changes: 113 additions & 0 deletions config/development.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
server:
host: "localhost"
port: 3000

db:
host: "localhost"
port: 5432
user: "postgres"
password: "postgres"

backend:
buzzer:
song:
- "-n"
- "-f880"
- "-l100"
- "-d0"
- "-n"
- "-f988"
- "-l100"
- "-d0"
- "-n"
- "-f588"
- "-l100"
- "-d0"
- "-n"
- "-f989"
- "-l100"
- "-d0"
- "-n"
- "-f660"
- "-l200"
- "-d0"
- "-n"
- "-f660"
- "-l200"
- "-d0"
- "-n"
- "-f588"
- "-l100"
- "-d0"
- "-n"
- "-f555"
- "-l100"
- "-d0"
- "-n"
- "-f495"
- "-l100"
- "-d0"

event:
website: "https://zeus.gent/events"
website_poster: "https://git.zeus.gent/ZeusWPI/visueel/raw/branch/master"
interval_s: 3600

gamification:
api: "https://gamification.zeus.gent"
interval_s: 3600

song:
spotify_api: "https://api.spotify.com/v1"
spotify_api_account: "https://accounts.spotify.com/api/token"
lrclib_api: "https://lrclib.net/api"

tap:
api: "https://tap.zeus.gent"
beers:
- "Schelfaut"
- "Duvel"
- "Fourchette"
- "Jupiler"
- "Karmeliet"
- "Kriek"
- "Chouffe"
- "Maes"
- "Somersby"
- "Sportzot"
- "Stella"
interval_s: 60

zess:
api: "https://zess.zeus.gent/api"
interval_season_s: 300
interval_scan_s: 60


tui:
screen:
cammie:
interval_s: 300

view:
event:
interval_s: 3600

gamification:
interval_s: 3600

message:
interval_s: 1

song:
interval_current_s: 5
interval_history_s: 5
interval_top_s: 3600

tap:
interval_s: 60

zess:
weeks: 10
interval_scan_s: 60
interval_season_s: 3600
Empty file removed config/production.toml
Empty file.
86 changes: 86 additions & 0 deletions config/production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# [server]
# host = "localhost"
# port = 3000

# [db]
# host = "localhost"
# port = 5432
# database = "scc"
# user = "postgres"
# password = "postgres"

# [song]
# spotify_api = "https://api.spotify.com/v1"
# spotify_account = "https://accounts.spotify.com/api/token"
# lrclib_api = "https://lrclib.net/api"

# [tap]
# api = "https://tap.zeus.gent"
# interval_s = 60
# beers = [
# "Schelfaut",
# "Duvel",
# "Fourchette",
# "Jupiler",
# "Karmeliet",
# "Kriek",
# "Chouffe",
# "Maes",
# "Somersby",
# "Sportzot",
# "Stella",
# ]

# [zess]
# api = "http://localhost:4000/api"
# interval_season_s = 300
# interval_scan_s = 60

# [gamification]
# api = "https://gamification.zeus.gent"
# interval_s = 3600

# [event]
# api = "https://zeus.gent/events"
# api_poster = "https://git.zeus.gent/ZeusWPI/visueel/raw/branch/master"
# interval_s = 86400

# [buzzer]
# song = [
# "-n", "-f880", "-l100", "-d0",
# "-n", "-f988", "-l100", "-d0",
# "-n", "-f588", "-l100", "-d0",
# "-n", "-f989", "-l100", "-d0",
# "-n", "-f660", "-l200", "-d0",
# "-n", "-f660", "-l200", "-d0",
# "-n", "-f588", "-l100", "-d0",
# "-n", "-f555", "-l100", "-d0",
# "-n", "-f495", "-l100", "-d0",
# ]

# [tui]

# [tui.screen]
# cammie_interval_change_s = 300

# [tui.zess]
# weeks = 10
# interval_scan_s = 60
# interval_season_s = 3600

# [tui.message]
# interval_s = 1

# [tui.tap]
# interval_s = 60

# [tui.gamification]
# interval_s = 3600

# [tui.song]
# interval_current_s = 5
# interval_history_s = 5
# interval_top_s = 3600

# [tui.event]
# interval_s = 3600
6 changes: 3 additions & 3 deletions db/migrations/20241121141143_add_zess_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
CREATE TABLE IF NOT EXISTS season (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
start TIMESTAMP WITH TIME ZONE NOT NULL,
"end" TIMESTAMP WITH TIME ZONE NOT NULL
start TIMESTAMP WITHOUT TIME ZONE NOT NULL,
"end" TIMESTAMP WITHOUT TIME ZONE NOT NULL
);

CREATE TABLE IF NOT EXISTS scan (
id INTEGER PRIMARY KEY,
id SERIAL PRIMARY KEY,
scan_time TIMESTAMP WITH TIME ZONE NOT NULL
);
-- +goose StatementEnd
Expand Down
4 changes: 4 additions & 0 deletions db/queries/season.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ RETURNING *;
DELETE FROM season
WHERE id = $1;

-- name: DeleteSeasonAll :execrows
DELETE FROM season;



-- Other

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func API(db *db.DB, song *song.Song) {
apiGroup := app.Group("/api")
api.New(apiGroup, db, song)

host := config.GetDefaultString("server.host", "127.0.0.1")
host := config.GetDefaultString("server.host", "localhost")
port := config.GetDefaultInt("server.port", 3000)

zap.S().Fatal("API: Fatal server error", app.Listen(fmt.Sprintf("%s:%d", host, port)))
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func Event(db *db.DB) (*event.Event, chan bool) {
}

func eventPeriodicUpdate(ev *event.Event, done chan bool) {
interval := config.GetDefaultInt("event.interval_s", 3600)
zap.S().Info("EventL Starting periodic leaderboard update with an interval of ", interval, " seconds")
interval := config.GetDefaultInt("backend.event.interval_s", 3600)
zap.S().Info("Event: Starting periodic leaderboard update with an interval of ", interval, " seconds")

ticker := time.NewTimer(time.Duration(interval) * time.Second)
defer ticker.Stop()
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/gamification.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func Gamification(db *db.DB) (*gamification.Gamification, chan bool) {
}

func gamificationPeriodicUpdate(gam *gamification.Gamification, done chan bool) {
interval := config.GetDefaultInt("gamification.interval_s", 3600)
interval := config.GetDefaultInt("backend.gamification.interval_s", 3600)
zap.S().Info("Gamification: Starting periodic leaderboard update with an interval of ", interval, " seconds")

ticker := time.NewTicker(time.Duration(interval) * time.Second)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/tap.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func Tap(db *db.DB) (*tap.Tap, chan bool) {
}

func tapPeriodicUpdate(tap *tap.Tap, done chan bool) {
interval := config.GetDefaultInt("tap.interval_s", 60)
interval := config.GetDefaultInt("backend.tap.interval_s", 60)
zap.S().Info("Tap: Starting periodic update with an interval of ", interval, " seconds")

ticker := time.NewTicker(time.Duration(interval) * time.Second)
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/zess.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func Zess(db *db.DB) (*zess.Zess, chan bool, chan bool) {
}

func zessPeriodicSeasonUpdate(zess *zess.Zess, done chan bool) {
interval := config.GetDefaultInt("zess.interval_season_s", 300)
interval := config.GetDefaultInt("backend.zess.interval_season_s", 300)
zap.S().Info("Zess: Starting periodic season update with an interval of ", interval, " seconds")

ticker := time.NewTicker(time.Duration(interval) * time.Second)
Expand Down Expand Up @@ -50,7 +50,7 @@ func zessPeriodicSeasonUpdate(zess *zess.Zess, done chan bool) {
}

func zessPeriodicScanUpdate(zess *zess.Zess, done chan bool) {
interval := config.GetDefaultInt("zess.interval_scan_s", 60)
interval := config.GetDefaultInt("backend.zess.interval_scan_s", 60)
zap.S().Info("Zess: Starting periodic scan update with an interval of ", interval, " seconds")

ticker := time.NewTicker(time.Duration(interval) * time.Second)
Expand Down
Loading

0 comments on commit 0696f11

Please sign in to comment.