Koito/internal/repository/users.sql.go
Gabe Farrell 36f984a1a2
Pre-release version v0.0.14 (#96)
* 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>
2025-11-19 20:26:56 -05:00

210 lines
4.6 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: users.sql
package repository
import (
"context"
)
const countApiKeys = `-- name: CountApiKeys :one
SELECT COUNT(*) FROM api_keys WHERE user_id = $1
`
func (q *Queries) CountApiKeys(ctx context.Context, userID int32) (int64, error) {
row := q.db.QueryRow(ctx, countApiKeys, userID)
var count int64
err := row.Scan(&count)
return count, err
}
const countUsers = `-- name: CountUsers :one
SELECT COUNT(*) FROM users
`
func (q *Queries) CountUsers(ctx context.Context) (int64, error) {
row := q.db.QueryRow(ctx, countUsers)
var count int64
err := row.Scan(&count)
return count, err
}
const deleteApiKey = `-- name: DeleteApiKey :exec
DELETE FROM api_keys WHERE id = $1
`
func (q *Queries) DeleteApiKey(ctx context.Context, id int32) error {
_, err := q.db.Exec(ctx, deleteApiKey, id)
return err
}
const deleteUser = `-- name: DeleteUser :exec
DELETE FROM users WHERE id = $1
`
func (q *Queries) DeleteUser(ctx context.Context, id int32) error {
_, err := q.db.Exec(ctx, deleteUser, id)
return err
}
const getAllApiKeysByUserID = `-- name: GetAllApiKeysByUserID :many
SELECT ak.id, ak.key, ak.user_id, ak.created_at, ak.label
FROM api_keys ak
JOIN users u ON ak.user_id = u.id
WHERE u.id = $1
`
func (q *Queries) GetAllApiKeysByUserID(ctx context.Context, id int32) ([]ApiKey, error) {
rows, err := q.db.Query(ctx, getAllApiKeysByUserID, id)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ApiKey
for rows.Next() {
var i ApiKey
if err := rows.Scan(
&i.ID,
&i.Key,
&i.UserID,
&i.CreatedAt,
&i.Label,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getUserByApiKey = `-- name: GetUserByApiKey :one
SELECT u.id, u.username, u.role, u.password
FROM users u
JOIN api_keys ak ON u.id = ak.user_id
WHERE ak.key = $1
`
func (q *Queries) GetUserByApiKey(ctx context.Context, key string) (User, error) {
row := q.db.QueryRow(ctx, getUserByApiKey, key)
var i User
err := row.Scan(
&i.ID,
&i.Username,
&i.Role,
&i.Password,
)
return i, err
}
const getUserByUsername = `-- name: GetUserByUsername :one
SELECT id, username, role, password FROM users WHERE username = $1
`
func (q *Queries) GetUserByUsername(ctx context.Context, username string) (User, error) {
row := q.db.QueryRow(ctx, getUserByUsername, username)
var i User
err := row.Scan(
&i.ID,
&i.Username,
&i.Role,
&i.Password,
)
return i, err
}
const insertApiKey = `-- name: InsertApiKey :one
INSERT INTO api_keys (user_id, key, label)
VALUES ($1, $2, $3)
RETURNING id, key, user_id, created_at, label
`
type InsertApiKeyParams struct {
UserID int32
Key string
Label string
}
func (q *Queries) InsertApiKey(ctx context.Context, arg InsertApiKeyParams) (ApiKey, error) {
row := q.db.QueryRow(ctx, insertApiKey, arg.UserID, arg.Key, arg.Label)
var i ApiKey
err := row.Scan(
&i.ID,
&i.Key,
&i.UserID,
&i.CreatedAt,
&i.Label,
)
return i, err
}
const insertUser = `-- name: InsertUser :one
INSERT INTO users (username, password, role)
VALUES ($1, $2, $3)
RETURNING id, username, role, password
`
type InsertUserParams struct {
Username string
Password []byte
Role Role
}
func (q *Queries) InsertUser(ctx context.Context, arg InsertUserParams) (User, error) {
row := q.db.QueryRow(ctx, insertUser, arg.Username, arg.Password, arg.Role)
var i User
err := row.Scan(
&i.ID,
&i.Username,
&i.Role,
&i.Password,
)
return i, err
}
const updateApiKeyLabel = `-- name: UpdateApiKeyLabel :exec
UPDATE api_keys SET label = $3 WHERE id = $1 AND user_id = $2
`
type UpdateApiKeyLabelParams struct {
ID int32
UserID int32
Label string
}
func (q *Queries) UpdateApiKeyLabel(ctx context.Context, arg UpdateApiKeyLabelParams) error {
_, err := q.db.Exec(ctx, updateApiKeyLabel, arg.ID, arg.UserID, arg.Label)
return err
}
const updateUserPassword = `-- name: UpdateUserPassword :exec
UPDATE users SET password = $2 WHERE id = $1
`
type UpdateUserPasswordParams struct {
ID int32
Password []byte
}
func (q *Queries) UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error {
_, err := q.db.Exec(ctx, updateUserPassword, arg.ID, arg.Password)
return err
}
const updateUserUsername = `-- name: UpdateUserUsername :exec
UPDATE users SET username = $2 WHERE id = $1
`
type UpdateUserUsernameParams struct {
ID int32
Username string
}
func (q *Queries) UpdateUserUsername(ctx context.Context, arg UpdateUserUsernameParams) error {
_, err := q.db.Exec(ctx, updateUserUsername, arg.ID, arg.Username)
return err
}