mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-08 15:08:14 -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, $4)
|
|||
RETURNING *;
|
||||
|
||||
-- name: GetRelease :one
|
||||
SELECT
|
||||
SELECT
|
||||
*,
|
||||
get_artists_for_release(id) AS artists
|
||||
FROM releases_with_title
|
||||
|
|
@ -69,10 +69,20 @@ WHERE l.listened_at BETWEEN $1 AND $2;
|
|||
|
||||
-- name: CountReleasesFromArtist :one
|
||||
SELECT COUNT(*)
|
||||
FROM releases r
|
||||
FROM releases r
|
||||
JOIN artist_releases ar ON r.id = ar.release_id
|
||||
WHERE ar.artist_id = $1;
|
||||
|
||||
-- name: CountNewReleases :one
|
||||
SELECT COUNT(*) AS total_count
|
||||
FROM (
|
||||
SELECT t.release_id
|
||||
FROM listens l
|
||||
JOIN tracks t ON l.track_id = t.id
|
||||
GROUP BY t.release_id
|
||||
HAVING MIN(l.listened_at) BETWEEN $1 AND $2
|
||||
) first_appearances;
|
||||
|
||||
-- name: AssociateArtistToRelease :exec
|
||||
INSERT INTO artist_releases (artist_id, release_id, is_primary)
|
||||
VALUES ($1, $2, $3)
|
||||
|
|
@ -82,8 +92,8 @@ ON CONFLICT DO NOTHING;
|
|||
SELECT
|
||||
r.*,
|
||||
get_artists_for_release(r.id) AS artists
|
||||
FROM releases_with_title r
|
||||
WHERE r.image IS NULL
|
||||
FROM releases_with_title r
|
||||
WHERE r.image IS NULL
|
||||
AND r.id > $2
|
||||
ORDER BY r.id ASC
|
||||
LIMIT $1;
|
||||
|
|
@ -107,8 +117,8 @@ WHERE id = $1;
|
|||
-- name: DeleteRelease :exec
|
||||
DELETE FROM releases WHERE id = $1;
|
||||
|
||||
-- name: DeleteReleasesFromArtist :exec
|
||||
-- name: DeleteReleasesFromArtist :exec
|
||||
DELETE FROM releases r
|
||||
USING artist_releases ar
|
||||
WHERE ar.release_id = r.id
|
||||
AND ar.artist_id = $1;
|
||||
AND ar.artist_id = $1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue