mirror of
https://github.com/gabehf/Koito.git
synced 2026-04-22 12:01:52 -07:00
feat: v0.0.10 (#23)
* feat: single SOT for themes + basic custom support * fix: adjust colors for yuu theme * feat: Allow loading of environment variables from file (#20) * feat: allow loading of environment variables from file * Panic if a file for an environment variable cannot be read * Use log.Fatalf + os.Exit instead of panic * fix: remove supurfluous call to os.Exit() --------- Co-authored-by: adaexec <nixos-git.s1pht@simplelogin.com> Co-authored-by: Gabe Farrell <90876006+gabehf@users.noreply.github.com> * chore: add pr test workflow * chore: changelog * feat: make all activity grids configurable * fix: adjust activity grid style * fix: make background gradient consistent size * revert: remove year from activity grid opts * style: adjust top item list min size to 200px * feat: add support for custom themes * fix: stabilized the order of top items * chore: update changelog * feat: native import & export * fix: use correct request body for alias requests * fix: clear input when closing edit modal * chore: changelog * docs: make endpoint clearer for some apps * feat: add ui and handler for export * fix: fix pr test workflow --------- Co-authored-by: adaexec <78047743+adaexec@users.noreply.github.com> Co-authored-by: adaexec <nixos-git.s1pht@simplelogin.com>
This commit is contained in:
parent
486f5d0269
commit
c16b557c21
51 changed files with 1754 additions and 866 deletions
|
|
@ -256,7 +256,7 @@ JOIN artist_tracks at ON at.track_id = t.id
|
|||
JOIN artists_with_name a ON a.id = at.artist_id
|
||||
WHERE l.listened_at BETWEEN $1 AND $2
|
||||
GROUP BY a.id, a.name, a.musicbrainz_id, a.image, a.image_source, a.name
|
||||
ORDER BY listen_count DESC
|
||||
ORDER BY listen_count DESC, a.id
|
||||
LIMIT $3 OFFSET $4
|
||||
`
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
|
|
@ -451,6 +452,138 @@ func (q *Queries) GetLastListensPaginated(ctx context.Context, arg GetLastListen
|
|||
return items, nil
|
||||
}
|
||||
|
||||
const getListensExportPage = `-- name: GetListensExportPage :many
|
||||
SELECT
|
||||
l.listened_at,
|
||||
l.user_id,
|
||||
l.client,
|
||||
|
||||
-- Track info
|
||||
t.id AS track_id,
|
||||
t.musicbrainz_id AS track_mbid,
|
||||
t.duration AS track_duration,
|
||||
(
|
||||
SELECT json_agg(json_build_object(
|
||||
'alias', ta.alias,
|
||||
'source', ta.source,
|
||||
'is_primary', ta.is_primary
|
||||
))
|
||||
FROM track_aliases ta
|
||||
WHERE ta.track_id = t.id
|
||||
) AS track_aliases,
|
||||
|
||||
-- Release info
|
||||
r.id AS release_id,
|
||||
r.musicbrainz_id AS release_mbid,
|
||||
r.image AS release_image,
|
||||
r.image_source AS release_image_source,
|
||||
r.various_artists,
|
||||
(
|
||||
SELECT json_agg(json_build_object(
|
||||
'alias', ra.alias,
|
||||
'source', ra.source,
|
||||
'is_primary', ra.is_primary
|
||||
))
|
||||
FROM release_aliases ra
|
||||
WHERE ra.release_id = r.id
|
||||
) AS release_aliases,
|
||||
|
||||
-- Artists
|
||||
(
|
||||
SELECT json_agg(json_build_object(
|
||||
'id', a.id,
|
||||
'musicbrainz_id', a.musicbrainz_id,
|
||||
'image', a.image,
|
||||
'image_source', a.image_source,
|
||||
'aliases', (
|
||||
SELECT json_agg(json_build_object(
|
||||
'alias', aa.alias,
|
||||
'source', aa.source,
|
||||
'is_primary', aa.is_primary
|
||||
))
|
||||
FROM artist_aliases aa
|
||||
WHERE aa.artist_id = a.id
|
||||
)
|
||||
))
|
||||
FROM artist_tracks at
|
||||
JOIN artists a ON a.id = at.artist_id
|
||||
WHERE at.track_id = t.id
|
||||
) AS artists
|
||||
|
||||
FROM listens l
|
||||
JOIN tracks t ON l.track_id = t.id
|
||||
JOIN releases r ON t.release_id = r.id
|
||||
|
||||
WHERE l.user_id = $2::int
|
||||
AND (l.listened_at, l.track_id) > ($3::timestamptz, $4::int)
|
||||
ORDER BY l.listened_at, l.track_id
|
||||
LIMIT $1
|
||||
`
|
||||
|
||||
type GetListensExportPageParams struct {
|
||||
Limit int32
|
||||
UserID int32
|
||||
ListenedAt time.Time
|
||||
TrackID int32
|
||||
}
|
||||
|
||||
type GetListensExportPageRow struct {
|
||||
ListenedAt time.Time
|
||||
UserID int32
|
||||
Client *string
|
||||
TrackID int32
|
||||
TrackMbid *uuid.UUID
|
||||
TrackDuration int32
|
||||
TrackAliases []byte
|
||||
ReleaseID int32
|
||||
ReleaseMbid *uuid.UUID
|
||||
ReleaseImage *uuid.UUID
|
||||
ReleaseImageSource pgtype.Text
|
||||
VariousArtists bool
|
||||
ReleaseAliases []byte
|
||||
Artists []byte
|
||||
}
|
||||
|
||||
func (q *Queries) GetListensExportPage(ctx context.Context, arg GetListensExportPageParams) ([]GetListensExportPageRow, error) {
|
||||
rows, err := q.db.Query(ctx, getListensExportPage,
|
||||
arg.Limit,
|
||||
arg.UserID,
|
||||
arg.ListenedAt,
|
||||
arg.TrackID,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetListensExportPageRow
|
||||
for rows.Next() {
|
||||
var i GetListensExportPageRow
|
||||
if err := rows.Scan(
|
||||
&i.ListenedAt,
|
||||
&i.UserID,
|
||||
&i.Client,
|
||||
&i.TrackID,
|
||||
&i.TrackMbid,
|
||||
&i.TrackDuration,
|
||||
&i.TrackAliases,
|
||||
&i.ReleaseID,
|
||||
&i.ReleaseMbid,
|
||||
&i.ReleaseImage,
|
||||
&i.ReleaseImageSource,
|
||||
&i.VariousArtists,
|
||||
&i.ReleaseAliases,
|
||||
&i.Artists,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const insertListen = `-- name: InsertListen :exec
|
||||
INSERT INTO listens (track_id, listened_at, user_id, client)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ JOIN artist_releases ar ON r.id = ar.release_id
|
|||
WHERE ar.artist_id = $5
|
||||
AND l.listened_at BETWEEN $1 AND $2
|
||||
GROUP BY r.id, r.title, r.musicbrainz_id, r.various_artists, r.image, r.image_source
|
||||
ORDER BY listen_count DESC
|
||||
ORDER BY listen_count DESC, r.id
|
||||
LIMIT $3 OFFSET $4
|
||||
`
|
||||
|
||||
|
|
@ -328,7 +328,7 @@ JOIN tracks t ON l.track_id = t.id
|
|||
JOIN releases_with_title r ON t.release_id = r.id
|
||||
WHERE l.listened_at BETWEEN $1 AND $2
|
||||
GROUP BY r.id, r.title, r.musicbrainz_id, r.various_artists, r.image, r.image_source
|
||||
ORDER BY listen_count DESC
|
||||
ORDER BY listen_count DESC, r.id
|
||||
LIMIT $3 OFFSET $4
|
||||
`
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ JOIN artist_tracks at ON at.track_id = t.id
|
|||
WHERE l.listened_at BETWEEN $1 AND $2
|
||||
AND at.artist_id = $5
|
||||
GROUP BY t.id, t.title, t.musicbrainz_id, t.release_id, r.image
|
||||
ORDER BY listen_count DESC
|
||||
ORDER BY listen_count DESC, t.id
|
||||
LIMIT $3 OFFSET $4
|
||||
`
|
||||
|
||||
|
|
@ -217,7 +217,7 @@ JOIN releases r ON t.release_id = r.id
|
|||
WHERE l.listened_at BETWEEN $1 AND $2
|
||||
AND t.release_id = $5
|
||||
GROUP BY t.id, t.title, t.musicbrainz_id, t.release_id, r.image
|
||||
ORDER BY listen_count DESC
|
||||
ORDER BY listen_count DESC, t.id
|
||||
LIMIT $3 OFFSET $4
|
||||
`
|
||||
|
||||
|
|
@ -287,7 +287,7 @@ JOIN tracks_with_title t ON l.track_id = t.id
|
|||
JOIN releases r ON t.release_id = r.id
|
||||
WHERE l.listened_at BETWEEN $1 AND $2
|
||||
GROUP BY t.id, t.title, t.musicbrainz_id, t.release_id, r.image
|
||||
ORDER BY listen_count DESC
|
||||
ORDER BY listen_count DESC, t.id
|
||||
LIMIT $3 OFFSET $4
|
||||
`
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue