mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-07 21:48:18 -08:00
* add dev branch container to workflow * correctly set the default range of ActivityGrid * fix: set name/short_name to koito (#61) * fix dev container push workflow * fix: race condition with using getComputedStyle primary color for dynamic activity grid darkening (#76) * Fix race condition with using getComputedStyle primary color for dynamic activity grid darkening Instead just use the color from the current theme directly. Tested works on initial load and theme changes. Fixes https://github.com/gabehf/Koito/issues/75 * Rework theme provider to provide the actual Theme object throughtout the app, in addition to the name Split name out of the Theme struct to simplify custom theme saving/reading * fix: set first artist listed as primary by default (#81) * feat: add server-side configuration with default theme (#90) * docs: add example for usage of the main listenbrainz instance (#71) * docs: add example for usage of the main listenbrainz instance * Update scrobbler.md --------- Co-authored-by: Gabe Farrell <90876006+gabehf@users.noreply.github.com> * feat: add server-side cfg and default theme * fix: repair custom theme --------- Co-authored-by: m0d3rnX <jesper@posteo.de> * docs: add default theme cfg option to docs * feat: add ability to manually scrobble track (#91) * feat: add button to manually scrobble from ui * fix: ensure timestamp is in the past, log fix * test: add integration test * feat: add first listened to dates for media items (#92) * fix: ensure error checks for ErrNoRows * feat: add now playing endpoint and ui (#93) * wip * feat: add now playing * fix: set default theme when config is not set * feat: fetch images from subsonic server (#94) * fix: useQuery instead of useEffect for now playing * feat: custom artist separator regex (#95) * Fix race condition with using getComputedStyle primary color for dynamic activity grid darkening Instead just use the color from the current theme directly. Tested works on initial load and theme changes. Fixes https://github.com/gabehf/Koito/issues/75 * Rework theme provider to provide the actual Theme object throughtout the app, in addition to the name Split name out of the Theme struct to simplify custom theme saving/reading * feat: add server-side configuration with default theme (#90) * docs: add example for usage of the main listenbrainz instance (#71) * docs: add example for usage of the main listenbrainz instance * Update scrobbler.md --------- Co-authored-by: Gabe Farrell <90876006+gabehf@users.noreply.github.com> * feat: add server-side cfg and default theme * fix: repair custom theme --------- Co-authored-by: m0d3rnX <jesper@posteo.de> * fix: rebase errors --------- Co-authored-by: pet <128837728+againstpetra@users.noreply.github.com> Co-authored-by: mlandry <mike.landry@gmail.com> Co-authored-by: m0d3rnX <jesper@posteo.de>
411 lines
8.9 KiB
Go
411 lines
8.9 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: search.sql
|
|
|
|
package repository
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const searchArtists = `-- name: SearchArtists :many
|
|
SELECT id, name, musicbrainz_id, image, score
|
|
FROM (
|
|
SELECT
|
|
a.id,
|
|
a.name,
|
|
a.musicbrainz_id,
|
|
a.image,
|
|
similarity(aa.alias, $1) AS score,
|
|
ROW_NUMBER() OVER (PARTITION BY a.id ORDER BY similarity(aa.alias, $1) DESC) AS rn
|
|
FROM artist_aliases aa
|
|
JOIN artists_with_name a ON aa.artist_id = a.id
|
|
WHERE similarity(aa.alias, $1) > 0.22
|
|
) ranked
|
|
WHERE rn = 1
|
|
ORDER BY score DESC
|
|
LIMIT $2
|
|
`
|
|
|
|
type SearchArtistsParams struct {
|
|
Similarity string
|
|
Limit int32
|
|
}
|
|
|
|
type SearchArtistsRow struct {
|
|
ID int32
|
|
Name string
|
|
MusicBrainzID *uuid.UUID
|
|
Image *uuid.UUID
|
|
Score float32
|
|
}
|
|
|
|
func (q *Queries) SearchArtists(ctx context.Context, arg SearchArtistsParams) ([]SearchArtistsRow, error) {
|
|
rows, err := q.db.Query(ctx, searchArtists, arg.Similarity, arg.Limit)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []SearchArtistsRow
|
|
for rows.Next() {
|
|
var i SearchArtistsRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.MusicBrainzID,
|
|
&i.Image,
|
|
&i.Score,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const searchArtistsBySubstring = `-- name: SearchArtistsBySubstring :many
|
|
SELECT id, name, musicbrainz_id, image, score
|
|
FROM (
|
|
SELECT
|
|
a.id,
|
|
a.name,
|
|
a.musicbrainz_id,
|
|
a.image,
|
|
1.0 AS score, -- why
|
|
ROW_NUMBER() OVER (PARTITION BY a.id ORDER BY aa.alias) AS rn
|
|
FROM artist_aliases aa
|
|
JOIN artists_with_name a ON aa.artist_id = a.id
|
|
WHERE aa.alias ILIKE $1 || '%'
|
|
) ranked
|
|
WHERE rn = 1
|
|
ORDER BY score DESC
|
|
LIMIT $2
|
|
`
|
|
|
|
type SearchArtistsBySubstringParams struct {
|
|
Column1 pgtype.Text
|
|
Limit int32
|
|
}
|
|
|
|
type SearchArtistsBySubstringRow struct {
|
|
ID int32
|
|
Name string
|
|
MusicBrainzID *uuid.UUID
|
|
Image *uuid.UUID
|
|
Score float64
|
|
}
|
|
|
|
func (q *Queries) SearchArtistsBySubstring(ctx context.Context, arg SearchArtistsBySubstringParams) ([]SearchArtistsBySubstringRow, error) {
|
|
rows, err := q.db.Query(ctx, searchArtistsBySubstring, arg.Column1, arg.Limit)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []SearchArtistsBySubstringRow
|
|
for rows.Next() {
|
|
var i SearchArtistsBySubstringRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.MusicBrainzID,
|
|
&i.Image,
|
|
&i.Score,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const searchReleases = `-- name: SearchReleases :many
|
|
SELECT
|
|
ranked.id,
|
|
ranked.title,
|
|
ranked.musicbrainz_id,
|
|
ranked.image,
|
|
ranked.various_artists,
|
|
ranked.score,
|
|
get_artists_for_release(ranked.id) AS artists
|
|
FROM (
|
|
SELECT
|
|
r.id,
|
|
r.title,
|
|
r.musicbrainz_id,
|
|
r.image,
|
|
r.various_artists,
|
|
similarity(ra.alias, $1) AS score,
|
|
ROW_NUMBER() OVER (PARTITION BY r.id ORDER BY similarity(ra.alias, $1) DESC) AS rn
|
|
FROM release_aliases ra
|
|
JOIN releases_with_title r ON ra.release_id = r.id
|
|
WHERE similarity(ra.alias, $1) > 0.22
|
|
) ranked
|
|
WHERE rn = 1
|
|
ORDER BY score DESC, title
|
|
LIMIT $2
|
|
`
|
|
|
|
type SearchReleasesParams struct {
|
|
Similarity string
|
|
Limit int32
|
|
}
|
|
|
|
type SearchReleasesRow struct {
|
|
ID int32
|
|
Title string
|
|
MusicBrainzID *uuid.UUID
|
|
Image *uuid.UUID
|
|
VariousArtists bool
|
|
Score float32
|
|
Artists []byte
|
|
}
|
|
|
|
func (q *Queries) SearchReleases(ctx context.Context, arg SearchReleasesParams) ([]SearchReleasesRow, error) {
|
|
rows, err := q.db.Query(ctx, searchReleases, arg.Similarity, arg.Limit)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []SearchReleasesRow
|
|
for rows.Next() {
|
|
var i SearchReleasesRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Title,
|
|
&i.MusicBrainzID,
|
|
&i.Image,
|
|
&i.VariousArtists,
|
|
&i.Score,
|
|
&i.Artists,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const searchReleasesBySubstring = `-- name: SearchReleasesBySubstring :many
|
|
SELECT
|
|
ranked.id,
|
|
ranked.title,
|
|
ranked.musicbrainz_id,
|
|
ranked.image,
|
|
ranked.various_artists,
|
|
ranked.score,
|
|
get_artists_for_release(ranked.id) AS artists
|
|
FROM (
|
|
SELECT
|
|
r.id,
|
|
r.title,
|
|
r.musicbrainz_id,
|
|
r.image,
|
|
r.various_artists,
|
|
1.0 AS score, -- idk why
|
|
ROW_NUMBER() OVER (PARTITION BY r.id ORDER BY ra.alias) AS rn
|
|
FROM release_aliases ra
|
|
JOIN releases_with_title r ON ra.release_id = r.id
|
|
WHERE ra.alias ILIKE $1 || '%'
|
|
) ranked
|
|
WHERE rn = 1
|
|
ORDER BY score DESC, title
|
|
LIMIT $2
|
|
`
|
|
|
|
type SearchReleasesBySubstringParams struct {
|
|
Column1 pgtype.Text
|
|
Limit int32
|
|
}
|
|
|
|
type SearchReleasesBySubstringRow struct {
|
|
ID int32
|
|
Title string
|
|
MusicBrainzID *uuid.UUID
|
|
Image *uuid.UUID
|
|
VariousArtists bool
|
|
Score float64
|
|
Artists []byte
|
|
}
|
|
|
|
func (q *Queries) SearchReleasesBySubstring(ctx context.Context, arg SearchReleasesBySubstringParams) ([]SearchReleasesBySubstringRow, error) {
|
|
rows, err := q.db.Query(ctx, searchReleasesBySubstring, arg.Column1, arg.Limit)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []SearchReleasesBySubstringRow
|
|
for rows.Next() {
|
|
var i SearchReleasesBySubstringRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Title,
|
|
&i.MusicBrainzID,
|
|
&i.Image,
|
|
&i.VariousArtists,
|
|
&i.Score,
|
|
&i.Artists,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const searchTracks = `-- name: SearchTracks :many
|
|
SELECT
|
|
ranked.id,
|
|
ranked.title,
|
|
ranked.musicbrainz_id,
|
|
ranked.release_id,
|
|
ranked.image,
|
|
ranked.score,
|
|
get_artists_for_track(ranked.id) AS artists
|
|
FROM (
|
|
SELECT
|
|
t.id,
|
|
t.title,
|
|
t.musicbrainz_id,
|
|
t.release_id,
|
|
r.image,
|
|
similarity(ta.alias, $1) AS score,
|
|
ROW_NUMBER() OVER (PARTITION BY t.id ORDER BY similarity(ta.alias, $1) DESC) AS rn
|
|
FROM track_aliases ta
|
|
JOIN tracks_with_title t ON ta.track_id = t.id
|
|
JOIN releases r ON t.release_id = r.id
|
|
WHERE similarity(ta.alias, $1) > 0.22
|
|
) ranked
|
|
WHERE rn = 1
|
|
ORDER BY score DESC, title
|
|
LIMIT $2
|
|
`
|
|
|
|
type SearchTracksParams struct {
|
|
Similarity string
|
|
Limit int32
|
|
}
|
|
|
|
type SearchTracksRow struct {
|
|
ID int32
|
|
Title string
|
|
MusicBrainzID *uuid.UUID
|
|
ReleaseID int32
|
|
Image *uuid.UUID
|
|
Score float32
|
|
Artists []byte
|
|
}
|
|
|
|
func (q *Queries) SearchTracks(ctx context.Context, arg SearchTracksParams) ([]SearchTracksRow, error) {
|
|
rows, err := q.db.Query(ctx, searchTracks, arg.Similarity, arg.Limit)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []SearchTracksRow
|
|
for rows.Next() {
|
|
var i SearchTracksRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Title,
|
|
&i.MusicBrainzID,
|
|
&i.ReleaseID,
|
|
&i.Image,
|
|
&i.Score,
|
|
&i.Artists,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const searchTracksBySubstring = `-- name: SearchTracksBySubstring :many
|
|
SELECT
|
|
ranked.id,
|
|
ranked.title,
|
|
ranked.musicbrainz_id,
|
|
ranked.release_id,
|
|
ranked.image,
|
|
ranked.score,
|
|
get_artists_for_track(ranked.id) AS artists
|
|
FROM (
|
|
SELECT
|
|
t.id,
|
|
t.title,
|
|
t.musicbrainz_id,
|
|
t.release_id,
|
|
r.image,
|
|
1.0 AS score,
|
|
ROW_NUMBER() OVER (PARTITION BY t.id ORDER BY ta.alias) AS rn
|
|
FROM track_aliases ta
|
|
JOIN tracks_with_title t ON ta.track_id = t.id
|
|
JOIN releases r ON t.release_id = r.id
|
|
WHERE ta.alias ILIKE $1 || '%'
|
|
) ranked
|
|
WHERE rn = 1
|
|
ORDER BY score DESC, title
|
|
LIMIT $2
|
|
`
|
|
|
|
type SearchTracksBySubstringParams struct {
|
|
Column1 pgtype.Text
|
|
Limit int32
|
|
}
|
|
|
|
type SearchTracksBySubstringRow struct {
|
|
ID int32
|
|
Title string
|
|
MusicBrainzID *uuid.UUID
|
|
ReleaseID int32
|
|
Image *uuid.UUID
|
|
Score float64
|
|
Artists []byte
|
|
}
|
|
|
|
func (q *Queries) SearchTracksBySubstring(ctx context.Context, arg SearchTracksBySubstringParams) ([]SearchTracksBySubstringRow, error) {
|
|
rows, err := q.db.Query(ctx, searchTracksBySubstring, arg.Column1, arg.Limit)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []SearchTracksBySubstringRow
|
|
for rows.Next() {
|
|
var i SearchTracksBySubstringRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Title,
|
|
&i.MusicBrainzID,
|
|
&i.ReleaseID,
|
|
&i.Image,
|
|
&i.Score,
|
|
&i.Artists,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|