2024-12-19 18:49:22 +00:00
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
|
// versions:
|
|
|
|
|
// sqlc v1.27.0
|
|
|
|
|
// source: result.sql
|
|
|
|
|
|
|
|
|
|
package repository
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
|
|
|
)
|
|
|
|
|
|
2024-12-20 17:35:33 +00:00
|
|
|
const listResultValuesByID = `-- name: ListResultValuesByID :many
|
|
|
|
|
SELECT id, queryId, value FROM results where id = ANY($1)
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type ListResultValuesByIDRow struct {
|
|
|
|
|
ID pgtype.UUID
|
|
|
|
|
Queryid pgtype.UUID
|
|
|
|
|
Value string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (q *Queries) ListResultValuesByID(ctx context.Context, id []pgtype.UUID) ([]ListResultValuesByIDRow, error) {
|
|
|
|
|
rows, err := q.db.Query(ctx, listResultValuesByID, id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
defer rows.Close()
|
|
|
|
|
var items []ListResultValuesByIDRow
|
|
|
|
|
for rows.Next() {
|
|
|
|
|
var i ListResultValuesByIDRow
|
|
|
|
|
if err := rows.Scan(&i.ID, &i.Queryid, &i.Value); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
items = append(items, i)
|
|
|
|
|
}
|
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return items, nil
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-19 18:49:22 +00:00
|
|
|
const listResultsByDocumentID = `-- name: ListResultsByDocumentID :many
|
2024-12-20 17:35:33 +00:00
|
|
|
SELECT id, queryId, queryVersion FROM results where documentId = $1 and cleanVersion >= $2 and textVersion >= $3
|
2024-12-19 18:49:22 +00:00
|
|
|
`
|
|
|
|
|
|
2024-12-19 19:49:40 +00:00
|
|
|
type ListResultsByDocumentIDParams struct {
|
|
|
|
|
Documentid pgtype.UUID
|
|
|
|
|
Cleanversion int32
|
|
|
|
|
Textversion int32
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-19 18:49:22 +00:00
|
|
|
type ListResultsByDocumentIDRow struct {
|
|
|
|
|
ID pgtype.UUID
|
|
|
|
|
Queryid pgtype.UUID
|
|
|
|
|
Queryversion int32
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-19 19:49:40 +00:00
|
|
|
func (q *Queries) ListResultsByDocumentID(ctx context.Context, arg ListResultsByDocumentIDParams) ([]ListResultsByDocumentIDRow, error) {
|
|
|
|
|
rows, err := q.db.Query(ctx, listResultsByDocumentID, arg.Documentid, arg.Cleanversion, arg.Textversion)
|
2024-12-19 18:49:22 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
defer rows.Close()
|
|
|
|
|
var items []ListResultsByDocumentIDRow
|
|
|
|
|
for rows.Next() {
|
|
|
|
|
var i ListResultsByDocumentIDRow
|
2024-12-20 17:35:33 +00:00
|
|
|
if err := rows.Scan(&i.ID, &i.Queryid, &i.Queryversion); err != nil {
|
2024-12-19 18:49:22 +00:00
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
items = append(items, i)
|
|
|
|
|
}
|
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return items, nil
|
|
|
|
|
}
|
2024-12-20 17:35:33 +00:00
|
|
|
|
|
|
|
|
const setResult = `-- name: SetResult :exec
|
|
|
|
|
INSERT INTO results (id, queryId, documentId, value, cleanVersion, textVersion, queryVersion) VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type SetResultParams struct {
|
|
|
|
|
ID pgtype.UUID
|
|
|
|
|
Queryid pgtype.UUID
|
|
|
|
|
Documentid pgtype.UUID
|
|
|
|
|
Value string
|
|
|
|
|
Cleanversion int32
|
|
|
|
|
Textversion int32
|
|
|
|
|
Queryversion int32
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (q *Queries) SetResult(ctx context.Context, arg SetResultParams) error {
|
|
|
|
|
_, err := q.db.Exec(ctx, setResult,
|
|
|
|
|
arg.ID,
|
|
|
|
|
arg.Queryid,
|
|
|
|
|
arg.Documentid,
|
|
|
|
|
arg.Value,
|
|
|
|
|
arg.Cleanversion,
|
|
|
|
|
arg.Textversion,
|
|
|
|
|
arg.Queryversion,
|
|
|
|
|
)
|
|
|
|
|
return err
|
|
|
|
|
}
|