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 {
|
2025-01-15 12:19:49 +00:00
|
|
|
ID pgtype.UUID `db:"id"`
|
|
|
|
|
Queryid pgtype.UUID `db:"queryid"`
|
|
|
|
|
Value string `db:"value"`
|
2024-12-20 17:35:33 +00:00
|
|
|
}
|
|
|
|
|
|
2025-01-15 12:19:49 +00:00
|
|
|
// ListResultValuesByID
|
|
|
|
|
//
|
|
|
|
|
// SELECT id, queryId, value FROM results where id = ANY($1)
|
|
|
|
|
func (q *Queries) ListResultValuesByID(ctx context.Context, id []pgtype.UUID) ([]*ListResultValuesByIDRow, error) {
|
2024-12-20 17:35:33 +00:00
|
|
|
rows, err := q.db.Query(ctx, listResultValuesByID, id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
defer rows.Close()
|
2025-01-15 12:19:49 +00:00
|
|
|
items := []*ListResultValuesByIDRow{}
|
2024-12-20 17:35:33 +00:00
|
|
|
for rows.Next() {
|
|
|
|
|
var i ListResultValuesByIDRow
|
|
|
|
|
if err := rows.Scan(&i.ID, &i.Queryid, &i.Value); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
2025-01-15 12:19:49 +00:00
|
|
|
items = append(items, &i)
|
2024-12-20 17:35:33 +00:00
|
|
|
}
|
|
|
|
|
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 {
|
2025-01-15 12:19:49 +00:00
|
|
|
Documentid pgtype.UUID `db:"documentid"`
|
|
|
|
|
Cleanversion int32 `db:"cleanversion"`
|
|
|
|
|
Textversion int32 `db:"textversion"`
|
2024-12-19 19:49:40 +00:00
|
|
|
}
|
|
|
|
|
|
2024-12-19 18:49:22 +00:00
|
|
|
type ListResultsByDocumentIDRow struct {
|
2025-01-15 12:19:49 +00:00
|
|
|
ID pgtype.UUID `db:"id"`
|
|
|
|
|
Queryid pgtype.UUID `db:"queryid"`
|
|
|
|
|
Queryversion int32 `db:"queryversion"`
|
2024-12-19 18:49:22 +00:00
|
|
|
}
|
|
|
|
|
|
2025-01-15 12:19:49 +00:00
|
|
|
// ListResultsByDocumentID
|
|
|
|
|
//
|
|
|
|
|
// SELECT id, queryId, queryVersion FROM results where documentId = $1 and cleanVersion >= $2 and textVersion >= $3
|
|
|
|
|
func (q *Queries) ListResultsByDocumentID(ctx context.Context, arg *ListResultsByDocumentIDParams) ([]*ListResultsByDocumentIDRow, error) {
|
2024-12-19 19:49:40 +00:00
|
|
|
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()
|
2025-01-15 12:19:49 +00:00
|
|
|
items := []*ListResultsByDocumentIDRow{}
|
2024-12-19 18:49:22 +00:00
|
|
|
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
|
|
|
|
|
}
|
2025-01-15 12:19:49 +00:00
|
|
|
items = append(items, &i)
|
2024-12-19 18:49:22 +00:00
|
|
|
}
|
|
|
|
|
if err := rows.Err(); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return items, nil
|
|
|
|
|
}
|
2024-12-20 17:35:33 +00:00
|
|
|
|
2025-01-03 13:47:19 +00:00
|
|
|
const setResult = `-- name: SetResult :one
|
|
|
|
|
INSERT INTO results (queryId, documentId, value, cleanVersion, textVersion, queryVersion) VALUES ($1, $2, $3, $4, $5, $6) RETURNING id
|
2024-12-20 17:35:33 +00:00
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type SetResultParams struct {
|
2025-01-15 12:19:49 +00:00
|
|
|
Queryid pgtype.UUID `db:"queryid"`
|
|
|
|
|
Documentid pgtype.UUID `db:"documentid"`
|
|
|
|
|
Value string `db:"value"`
|
|
|
|
|
Cleanversion int32 `db:"cleanversion"`
|
|
|
|
|
Textversion int32 `db:"textversion"`
|
|
|
|
|
Queryversion int32 `db:"queryversion"`
|
2024-12-20 17:35:33 +00:00
|
|
|
}
|
|
|
|
|
|
2025-01-15 12:19:49 +00:00
|
|
|
// SetResult
|
|
|
|
|
//
|
|
|
|
|
// INSERT INTO results (queryId, documentId, value, cleanVersion, textVersion, queryVersion) VALUES ($1, $2, $3, $4, $5, $6) RETURNING id
|
|
|
|
|
func (q *Queries) SetResult(ctx context.Context, arg *SetResultParams) (pgtype.UUID, error) {
|
2025-01-03 13:47:19 +00:00
|
|
|
row := q.db.QueryRow(ctx, setResult,
|
2024-12-20 17:35:33 +00:00
|
|
|
arg.Queryid,
|
|
|
|
|
arg.Documentid,
|
|
|
|
|
arg.Value,
|
|
|
|
|
arg.Cleanversion,
|
|
|
|
|
arg.Textversion,
|
|
|
|
|
arg.Queryversion,
|
|
|
|
|
)
|
2025-01-03 13:47:19 +00:00
|
|
|
var id pgtype.UUID
|
|
|
|
|
err := row.Scan(&id)
|
|
|
|
|
return id, err
|
2024-12-20 17:35:33 +00:00
|
|
|
}
|