Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/fractional #38

Merged
merged 9 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ tui:
song:
interval_current_s: 5
interval_history_s: 5
interval_top_s: 300
interval_monthly_stats_s: 300
interval_stats_s: 3600

tap:
interval_s: 60
Expand Down
86 changes: 0 additions & 86 deletions config/production.yaml
Original file line number Diff line number Diff line change
@@ -1,86 +0,0 @@
# [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
47 changes: 42 additions & 5 deletions db/queries/song.sql
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,15 @@ WHERE sh.created_at = (SELECT MAX(created_at) FROM song_history)
ORDER BY a.name, g.genre;

-- name: GetSongHistory :many
SELECT s.title
FROM song_history sh
JOIN song s ON sh.song_id = s.id
ORDER BY created_at DESC
LIMIT 10;
SELECT s.title, play_count, aggregated.created_at
FROM (
SELECT sh.song_id, MAX(sh.created_at) AS created_at, COUNT(sh.song_id) AS play_count
FROM song_history sh
GROUP BY sh.song_id
) aggregated
JOIN song s ON aggregated.song_id = s.id
ORDER BY aggregated.created_at DESC
LIMIT 50;

-- name: GetTopSongs :many
SELECT s.id AS song_id, s.title, COUNT(sh.id) AS play_count
Expand Down Expand Up @@ -106,3 +110,36 @@ JOIN song_genre g ON sag.genre_id = g.id
GROUP BY g.genre
ORDER BY total_plays DESC
LIMIT 10;

-- name: GetTopMonthlySongs :many
SELECT s.id AS song_id, s.title, COUNT(sh.id) AS play_count
FROM song_history sh
JOIN song s ON sh.song_id = s.id
WHERE sh.created_at > CURRENT_TIMESTAMP - INTERVAL '1 month'
GROUP BY s.id, s.title
ORDER BY play_count DESC
LIMIT 10;

-- name: GetTopMonthlyArtists :many
SELECT sa.id AS artist_id, sa.name AS artist_name, COUNT(sh.id) AS total_plays
FROM song_history sh
JOIN song s ON sh.song_id = s.id
JOIN song_artist_song sas ON s.id = sas.song_id
JOIN song_artist sa ON sas.artist_id = sa.id
WHERE sh.created_at > CURRENT_TIMESTAMP - INTERVAL '1 month'
GROUP BY sa.id, sa.name
ORDER BY total_plays DESC
LIMIT 10;

-- name: GetTopMonthlyGenres :many
SELECT g.genre AS genre_name, COUNT(sh.id) AS total_plays
FROM song_history sh
JOIN song s ON sh.song_id = s.id
JOIN song_artist_song sas ON s.id = sas.song_id
JOIN song_artist sa ON sas.artist_id = sa.id
JOIN song_artist_genre sag ON sa.id = sag.artist_id
JOIN song_genre g ON sag.genre_id = g.id
WHERE sh.created_at > CURRENT_TIMESTAMP - INTERVAL '1 month'
GROUP BY g.genre
ORDER BY total_plays DESC
LIMIT 10;
61 changes: 30 additions & 31 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ module github.com/zeusWPI/scc
go 1.23.1

require (
github.com/NimbleMarkets/ntcharts v0.2.0
github.com/charmbracelet/bubbles v0.20.0
github.com/NimbleMarkets/ntcharts v0.3.1
github.com/charmbracelet/bubbletea v1.2.4
github.com/charmbracelet/lipgloss v1.0.0
github.com/disintegration/imaging v1.6.2
github.com/go-playground/validator/v10 v10.23.0
github.com/gocolly/colly v1.2.0
github.com/gofiber/contrib/fiberzap v1.0.2
github.com/gofiber/fiber/v2 v2.52.5
github.com/jackc/pgx/v5 v5.7.1
github.com/jackc/pgx/v5 v5.7.2
github.com/joho/godotenv v1.5.1
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/spf13/viper v1.19.0
Expand All @@ -21,33 +20,33 @@ require (

require (
github.com/PuerkitoBio/goquery v1.10.0 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/antchfx/htmlquery v1.3.3 // indirect
github.com/antchfx/xmlquery v1.4.2 // indirect
github.com/antchfx/xpath v1.3.2 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/andybalholm/cascadia v1.3.3 // indirect
github.com/antchfx/htmlquery v1.3.4 // indirect
github.com/antchfx/xmlquery v1.4.3 // indirect
github.com/antchfx/xpath v1.3.3 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/harmonica v0.2.0 // indirect
github.com/charmbracelet/x/ansi v0.4.5 // indirect
github.com/charmbracelet/bubbles v0.20.0 // indirect
github.com/charmbracelet/x/ansi v0.6.0 // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.7 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/kennygrant/sanitize v1.2.4 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lrstanley/bubblezone v0.0.0-20240914071701-b48c55a5e78e // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/lrstanley/bubblezone v0.0.0-20241221063659-0f12a2876fb2 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
Expand All @@ -56,30 +55,30 @@ require (
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/temoto/robotstxt v1.1.2 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.51.0 // indirect
github.com/valyala/fasthttp v1.58.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 // indirect
golang.org/x/image v0.23.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.33.0 // indirect
google.golang.org/protobuf v1.36.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading