Nothing reached any of it: - MusicBrainz search (artists, albums, songs), artist lookups and the query escaping they used. The release-group lookups the duplicate resolver uses stay. - Release-group covers, and artist-level tags for artists not in the library. - Nine named queries with no caller (CountTracksByArtist went with the previous commit), two of them describing request-progress reporting. The MusicBrainz client's retry and not-found tests now drive the release-group lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: password_resets.sql
|
|
|
|
package dbq
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createPasswordReset = `-- name: CreatePasswordReset :exec
|
|
INSERT INTO password_resets (token, user_id, expires_at)
|
|
VALUES ($1, $2, $3)
|
|
`
|
|
|
|
type CreatePasswordResetParams struct {
|
|
Token string
|
|
UserID pgtype.UUID
|
|
ExpiresAt pgtype.Timestamptz
|
|
}
|
|
|
|
func (q *Queries) CreatePasswordReset(ctx context.Context, arg CreatePasswordResetParams) error {
|
|
_, err := q.db.Exec(ctx, createPasswordReset, arg.Token, arg.UserID, arg.ExpiresAt)
|
|
return err
|
|
}
|
|
|
|
const getPasswordReset = `-- name: GetPasswordReset :one
|
|
SELECT token, user_id, created_at, expires_at, used_at FROM password_resets WHERE token = $1
|
|
`
|
|
|
|
func (q *Queries) GetPasswordReset(ctx context.Context, token string) (PasswordReset, error) {
|
|
row := q.db.QueryRow(ctx, getPasswordReset, token)
|
|
var i PasswordReset
|
|
err := row.Scan(
|
|
&i.Token,
|
|
&i.UserID,
|
|
&i.CreatedAt,
|
|
&i.ExpiresAt,
|
|
&i.UsedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const usePasswordReset = `-- name: UsePasswordReset :execrows
|
|
UPDATE password_resets
|
|
SET used_at = now()
|
|
WHERE token = $1
|
|
AND used_at IS NULL
|
|
AND expires_at > now()
|
|
`
|
|
|
|
// Atomic claim: marks the token used only if currently unused
|
|
// and not expired. Returns rows-affected so the caller can
|
|
// distinguish "successful claim" (rows=1) from "already used /
|
|
// expired / nonexistent" (rows=0).
|
|
func (q *Queries) UsePasswordReset(ctx context.Context, token string) (int64, error) {
|
|
result, err := q.db.Exec(ctx, usePasswordReset, token)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected(), nil
|
|
}
|