efe87321b2
Testing Tweaks * parallel * slowestquery * split * cleanup * health * dynamiccores * go * profile * timeout * commitmychanges * taskfile * sqlcheckstart * client * cost * ctxtimeout
260 lines
7.4 KiB
Go
260 lines
7.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.27.0
|
|
// source: text.sql
|
|
|
|
package repository
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const addDocumentText = `-- name: AddDocumentText :one
|
|
INSERT INTO documentTextExtractions
|
|
(cleanId, bucket, key, hash, createdAt, part)
|
|
VALUES ($1, $2, $3, $4, $5, $6)
|
|
returning id
|
|
`
|
|
|
|
type AddDocumentTextParams struct {
|
|
Cleanid uuid.UUID `db:"cleanid"`
|
|
Bucket string `db:"bucket"`
|
|
Key string `db:"key"`
|
|
Hash string `db:"hash"`
|
|
Createdat pgtype.Timestamp `db:"createdat"`
|
|
Part uint16 `db:"part"`
|
|
}
|
|
|
|
// AddDocumentText
|
|
//
|
|
// INSERT INTO documentTextExtractions
|
|
// (cleanId, bucket, key, hash, createdAt, part)
|
|
// VALUES ($1, $2, $3, $4, $5, $6)
|
|
// returning id
|
|
func (q *Queries) AddDocumentText(ctx context.Context, arg *AddDocumentTextParams) (uuid.UUID, error) {
|
|
row := q.db.QueryRow(ctx, addDocumentText,
|
|
arg.Cleanid,
|
|
arg.Bucket,
|
|
arg.Key,
|
|
arg.Hash,
|
|
arg.Createdat,
|
|
arg.Part,
|
|
)
|
|
var id uuid.UUID
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
const addDocumentTextEntry = `-- name: AddDocumentTextEntry :exec
|
|
INSERT INTO documentTextExtractionEntries
|
|
(textId, version)
|
|
VALUES ($1, $2)
|
|
`
|
|
|
|
type AddDocumentTextEntryParams struct {
|
|
Textid uuid.UUID `db:"textid"`
|
|
Version int64 `db:"version"`
|
|
}
|
|
|
|
// AddDocumentTextEntry
|
|
//
|
|
// INSERT INTO documentTextExtractionEntries
|
|
// (textId, version)
|
|
// VALUES ($1, $2)
|
|
func (q *Queries) AddDocumentTextEntry(ctx context.Context, arg *AddDocumentTextEntryParams) error {
|
|
_, err := q.db.Exec(ctx, addDocumentTextEntry, arg.Textid, arg.Version)
|
|
return err
|
|
}
|
|
|
|
const getDocumentTextExtractionByHash = `-- name: GetDocumentTextExtractionByHash :one
|
|
SELECT id FROM currentTextEntries WHERE cleanId = $1 and hash = $2
|
|
`
|
|
|
|
type GetDocumentTextExtractionByHashParams struct {
|
|
Cleanentryid uuid.UUID `db:"cleanentryid"`
|
|
Hash string `db:"hash"`
|
|
}
|
|
|
|
// GetDocumentTextExtractionByHash
|
|
//
|
|
// SELECT id FROM currentTextEntries WHERE cleanId = $1 and hash = $2
|
|
func (q *Queries) GetDocumentTextExtractionByHash(ctx context.Context, arg *GetDocumentTextExtractionByHashParams) (uuid.UUID, error) {
|
|
row := q.db.QueryRow(ctx, getDocumentTextExtractionByHash, arg.Cleanentryid, arg.Hash)
|
|
var id uuid.UUID
|
|
err := row.Scan(&id)
|
|
return id, err
|
|
}
|
|
|
|
const getTextEntryByDocId = `-- name: GetTextEntryByDocId :one
|
|
SELECT id, documentId, bucket, key, hash, cleanId, extractionVersion
|
|
FROM currentTextEntries
|
|
WHERE documentId = $1
|
|
`
|
|
|
|
// GetTextEntryByDocId
|
|
//
|
|
// SELECT id, documentId, bucket, key, hash, cleanId, extractionVersion
|
|
// FROM currentTextEntries
|
|
// WHERE documentId = $1
|
|
func (q *Queries) GetTextEntryByDocId(ctx context.Context, documentid uuid.UUID) (*Currenttextentry, error) {
|
|
row := q.db.QueryRow(ctx, getTextEntryByDocId, documentid)
|
|
var i Currenttextentry
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Documentid,
|
|
&i.Bucket,
|
|
&i.Key,
|
|
&i.Hash,
|
|
&i.Cleanid,
|
|
&i.Extractionversion,
|
|
)
|
|
return &i, err
|
|
}
|
|
|
|
const getTextOutCurrentPart = `-- name: GetTextOutCurrentPart :one
|
|
WITH client as (
|
|
select clientId from clients where clientId = $1
|
|
),
|
|
parts as (
|
|
SELECT extract.part
|
|
FROM client as c
|
|
JOIN documents as docs on docs.clientId = c.clientId
|
|
JOIN documentCleans as clean on docs.id = clean.documentId
|
|
JOIN documentTextExtractions extract ON extract.cleanId = clean.id
|
|
WHERE date(extract.createdAt) = date($2)
|
|
),
|
|
max_part as (
|
|
SELECT COALESCE(max(part), 0) as max_part_num FROM parts
|
|
)
|
|
SELECT
|
|
COALESCE(p.part, 0)::unsignedsmallint as part,
|
|
COUNT(p.part) as count
|
|
FROM parts p
|
|
RIGHT JOIN max_part mp ON p.part = mp.max_part_num
|
|
GROUP BY p.part
|
|
`
|
|
|
|
type GetTextOutCurrentPartParams struct {
|
|
Clientid *string `db:"clientid"`
|
|
Querydate pgtype.Timestamptz `db:"querydate"`
|
|
}
|
|
|
|
type GetTextOutCurrentPartRow struct {
|
|
Part uint16 `db:"part"`
|
|
Count int64 `db:"count"`
|
|
}
|
|
|
|
// GetTextOutCurrentPart
|
|
//
|
|
// WITH client as (
|
|
// select clientId from clients where clientId = $1
|
|
// ),
|
|
// parts as (
|
|
// SELECT extract.part
|
|
// FROM client as c
|
|
// JOIN documents as docs on docs.clientId = c.clientId
|
|
// JOIN documentCleans as clean on docs.id = clean.documentId
|
|
// JOIN documentTextExtractions extract ON extract.cleanId = clean.id
|
|
// WHERE date(extract.createdAt) = date($2)
|
|
// ),
|
|
// max_part as (
|
|
// SELECT COALESCE(max(part), 0) as max_part_num FROM parts
|
|
// )
|
|
// SELECT
|
|
// COALESCE(p.part, 0)::unsignedsmallint as part,
|
|
// COUNT(p.part) as count
|
|
// FROM parts p
|
|
// RIGHT JOIN max_part mp ON p.part = mp.max_part_num
|
|
// GROUP BY p.part
|
|
func (q *Queries) GetTextOutCurrentPart(ctx context.Context, arg *GetTextOutCurrentPartParams) (*GetTextOutCurrentPartRow, error) {
|
|
row := q.db.QueryRow(ctx, getTextOutCurrentPart, arg.Clientid, arg.Querydate)
|
|
var i GetTextOutCurrentPartRow
|
|
err := row.Scan(&i.Part, &i.Count)
|
|
return &i, err
|
|
}
|
|
|
|
const getTextractOutputCurrentPart = `-- name: GetTextractOutputCurrentPart :one
|
|
WITH client as (
|
|
select clientId from clients where clientId = $1
|
|
),
|
|
parts as (
|
|
SELECT extract.part
|
|
FROM client as c
|
|
JOIN documents as docs on docs.clientId = c.clientId
|
|
JOIN documentCleans as clean on docs.id = clean.documentId
|
|
JOIN documentTextExtractions as extract
|
|
on extract.cleanId = clean.id
|
|
WHERE date(extract.createdAt) = date($2)
|
|
),
|
|
max_part as (
|
|
SELECT COALESCE(max(part), 0) as max_part_num FROM parts
|
|
)
|
|
SELECT
|
|
COALESCE(p.part, 0)::unsignedsmallint as part,
|
|
COUNT(p.part) as count
|
|
FROM parts p
|
|
RIGHT JOIN max_part mp ON p.part = mp.max_part_num
|
|
GROUP BY p.part
|
|
`
|
|
|
|
type GetTextractOutputCurrentPartParams struct {
|
|
Clientid *string `db:"clientid"`
|
|
Querydate pgtype.Timestamptz `db:"querydate"`
|
|
}
|
|
|
|
type GetTextractOutputCurrentPartRow struct {
|
|
Part uint16 `db:"part"`
|
|
Count int64 `db:"count"`
|
|
}
|
|
|
|
// GetTextractOutputCurrentPart
|
|
//
|
|
// WITH client as (
|
|
// select clientId from clients where clientId = $1
|
|
// ),
|
|
// parts as (
|
|
// SELECT extract.part
|
|
// FROM client as c
|
|
// JOIN documents as docs on docs.clientId = c.clientId
|
|
// JOIN documentCleans as clean on docs.id = clean.documentId
|
|
// JOIN documentTextExtractions as extract
|
|
// on extract.cleanId = clean.id
|
|
// WHERE date(extract.createdAt) = date($2)
|
|
// ),
|
|
// max_part as (
|
|
// SELECT COALESCE(max(part), 0) as max_part_num FROM parts
|
|
// )
|
|
// SELECT
|
|
// COALESCE(p.part, 0)::unsignedsmallint as part,
|
|
// COUNT(p.part) as count
|
|
// FROM parts p
|
|
// RIGHT JOIN max_part mp ON p.part = mp.max_part_num
|
|
// GROUP BY p.part
|
|
func (q *Queries) GetTextractOutputCurrentPart(ctx context.Context, arg *GetTextractOutputCurrentPartParams) (*GetTextractOutputCurrentPartRow, error) {
|
|
row := q.db.QueryRow(ctx, getTextractOutputCurrentPart, arg.Clientid, arg.Querydate)
|
|
var i GetTextractOutputCurrentPartRow
|
|
err := row.Scan(&i.Part, &i.Count)
|
|
return &i, err
|
|
}
|
|
|
|
const isDocumentTextExtracted = `-- name: IsDocumentTextExtracted :one
|
|
SELECT EXISTS(
|
|
SELECT 1 FROM currentTextEntries WHERE documentId = $1
|
|
)
|
|
`
|
|
|
|
// IsDocumentTextExtracted
|
|
//
|
|
// SELECT EXISTS(
|
|
// SELECT 1 FROM currentTextEntries WHERE documentId = $1
|
|
// )
|
|
func (q *Queries) IsDocumentTextExtracted(ctx context.Context, documentid uuid.UUID) (bool, error) {
|
|
row := q.db.QueryRow(ctx, isDocumentTextExtracted, documentid)
|
|
var exists bool
|
|
err := row.Scan(&exists)
|
|
return exists, err
|
|
}
|