mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-09 15:38:17 -07:00
feat: Rewind (#116)
* wip * chore: update counts to allow unix timeframe * feat: add db functions for counting new items * wip: endpoint working * wip * wip: initial ui done * add header, adjust ui * add time listened toggle * fix layout, year param * param fixes
This commit is contained in:
parent
c0a8c64243
commit
d4ac96f780
64 changed files with 2252 additions and 1055 deletions
|
|
@ -4,7 +4,7 @@ VALUES ($1, $2, $3)
|
|||
RETURNING *;
|
||||
|
||||
-- name: GetArtist :one
|
||||
SELECT
|
||||
SELECT
|
||||
a.*,
|
||||
array_agg(aa.alias)::text[] AS aliases
|
||||
FROM artists_with_name a
|
||||
|
|
@ -13,7 +13,7 @@ WHERE a.id = $1
|
|||
GROUP BY a.id, a.musicbrainz_id, a.image, a.image_source, a.name;
|
||||
|
||||
-- name: GetTrackArtists :many
|
||||
SELECT
|
||||
SELECT
|
||||
a.*,
|
||||
at.is_primary as is_primary
|
||||
FROM artists_with_name a
|
||||
|
|
@ -25,7 +25,7 @@ GROUP BY a.id, a.musicbrainz_id, a.image, a.image_source, a.name, at.is_primary;
|
|||
SELECT * FROM artists WHERE image = $1 LIMIT 1;
|
||||
|
||||
-- name: GetReleaseArtists :many
|
||||
SELECT
|
||||
SELECT
|
||||
a.*,
|
||||
ar.is_primary as is_primary
|
||||
FROM artists_with_name a
|
||||
|
|
@ -35,7 +35,7 @@ GROUP BY a.id, a.musicbrainz_id, a.image, a.image_source, a.name, ar.is_primary;
|
|||
|
||||
-- name: GetArtistByName :one
|
||||
WITH artist_with_aliases AS (
|
||||
SELECT
|
||||
SELECT
|
||||
a.*,
|
||||
COALESCE(array_agg(aa.alias), '{}')::text[] AS aliases
|
||||
FROM artists_with_name a
|
||||
|
|
@ -48,7 +48,7 @@ WITH artist_with_aliases AS (
|
|||
SELECT * FROM artist_with_aliases;
|
||||
|
||||
-- name: GetArtistByMbzID :one
|
||||
SELECT
|
||||
SELECT
|
||||
a.*,
|
||||
array_agg(aa.alias)::text[] AS aliases
|
||||
FROM artists_with_name a
|
||||
|
|
@ -78,6 +78,17 @@ FROM listens l
|
|||
JOIN artist_tracks at ON l.track_id = at.track_id
|
||||
WHERE l.listened_at BETWEEN $1 AND $2;
|
||||
|
||||
-- name: CountNewArtists :one
|
||||
SELECT COUNT(*) AS total_count
|
||||
FROM (
|
||||
SELECT at.artist_id
|
||||
FROM listens l
|
||||
JOIN tracks t ON l.track_id = t.id
|
||||
JOIN artist_tracks at ON t.id = at.track_id
|
||||
GROUP BY at.artist_id
|
||||
HAVING MIN(l.listened_at) BETWEEN $1 AND $2
|
||||
) first_appearances;
|
||||
|
||||
-- name: UpdateArtistMbzID :exec
|
||||
UPDATE artists SET musicbrainz_id = $2
|
||||
WHERE id = $1;
|
||||
|
|
@ -111,4 +122,4 @@ SET artist_id = $2
|
|||
WHERE artist_id = $1;
|
||||
|
||||
-- name: DeleteArtist :exec
|
||||
DELETE FROM artists WHERE id = $1;
|
||||
DELETE FROM artists WHERE id = $1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue