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>
120 lines
2.5 KiB
Go
120 lines
2.5 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: sessions.sql
|
|
|
|
package repository
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const deleteSession = `-- name: DeleteSession :exec
|
|
DELETE FROM sessions WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteSession(ctx context.Context, id uuid.UUID) error {
|
|
_, err := q.db.Exec(ctx, deleteSession, id)
|
|
return err
|
|
}
|
|
|
|
const getSession = `-- name: GetSession :one
|
|
SELECT id, user_id, created_at, expires_at, persistent FROM sessions WHERE id = $1 AND expires_at > NOW()
|
|
`
|
|
|
|
func (q *Queries) GetSession(ctx context.Context, id uuid.UUID) (Session, error) {
|
|
row := q.db.QueryRow(ctx, getSession, id)
|
|
var i Session
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.CreatedAt,
|
|
&i.ExpiresAt,
|
|
&i.Persistent,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserBySession = `-- name: GetUserBySession :one
|
|
SELECT u.id, username, role, password, s.id, user_id, created_at, expires_at, persistent
|
|
FROM users u
|
|
JOIN sessions s ON u.id = s.user_id
|
|
WHERE s.id = $1
|
|
`
|
|
|
|
type GetUserBySessionRow struct {
|
|
ID int32
|
|
Username string
|
|
Role Role
|
|
Password []byte
|
|
ID_2 uuid.UUID
|
|
UserID int32
|
|
CreatedAt time.Time
|
|
ExpiresAt time.Time
|
|
Persistent bool
|
|
}
|
|
|
|
func (q *Queries) GetUserBySession(ctx context.Context, id uuid.UUID) (GetUserBySessionRow, error) {
|
|
row := q.db.QueryRow(ctx, getUserBySession, id)
|
|
var i GetUserBySessionRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Username,
|
|
&i.Role,
|
|
&i.Password,
|
|
&i.ID_2,
|
|
&i.UserID,
|
|
&i.CreatedAt,
|
|
&i.ExpiresAt,
|
|
&i.Persistent,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const insertSession = `-- name: InsertSession :one
|
|
INSERT INTO sessions (id, user_id, expires_at, persistent)
|
|
VALUES ($1, $2, $3, $4)
|
|
RETURNING id, user_id, created_at, expires_at, persistent
|
|
`
|
|
|
|
type InsertSessionParams struct {
|
|
ID uuid.UUID
|
|
UserID int32
|
|
ExpiresAt time.Time
|
|
Persistent bool
|
|
}
|
|
|
|
func (q *Queries) InsertSession(ctx context.Context, arg InsertSessionParams) (Session, error) {
|
|
row := q.db.QueryRow(ctx, insertSession,
|
|
arg.ID,
|
|
arg.UserID,
|
|
arg.ExpiresAt,
|
|
arg.Persistent,
|
|
)
|
|
var i Session
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.CreatedAt,
|
|
&i.ExpiresAt,
|
|
&i.Persistent,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateSessionExpiry = `-- name: UpdateSessionExpiry :exec
|
|
UPDATE sessions SET expires_at = $2 WHERE id = $1
|
|
`
|
|
|
|
type UpdateSessionExpiryParams struct {
|
|
ID uuid.UUID
|
|
ExpiresAt time.Time
|
|
}
|
|
|
|
func (q *Queries) UpdateSessionExpiry(ctx context.Context, arg UpdateSessionExpiryParams) error {
|
|
_, err := q.db.Exec(ctx, updateSessionExpiry, arg.ID, arg.ExpiresAt)
|
|
return err
|
|
}
|