Merged in feature/textExtractionsPart1 (pull request #192)
all schema and rest apis for text extraction support * in progress * stage 8 complete * phase 9 completed * phase 9 complete * ongoing - s3 path fix * working * optimize ci build * e2e tests * missing test
This commit is contained in:
@@ -0,0 +1,318 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
// source: labels.sql
|
||||
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const applyLabel = `-- name: ApplyLabel :one
|
||||
INSERT INTO documentLabels (documentId, label, appliedBy)
|
||||
VALUES ($1, $2, $3)
|
||||
RETURNING id, documentid, label, appliedat, appliedby
|
||||
`
|
||||
|
||||
type ApplyLabelParams struct {
|
||||
Documentid uuid.UUID `db:"documentid"`
|
||||
Label string `db:"label"`
|
||||
Appliedby string `db:"appliedby"`
|
||||
}
|
||||
|
||||
// ApplyLabel
|
||||
//
|
||||
// INSERT INTO documentLabels (documentId, label, appliedBy)
|
||||
// VALUES ($1, $2, $3)
|
||||
// RETURNING id, documentid, label, appliedat, appliedby
|
||||
func (q *Queries) ApplyLabel(ctx context.Context, arg *ApplyLabelParams) (*Documentlabel, error) {
|
||||
row := q.db.QueryRow(ctx, applyLabel, arg.Documentid, arg.Label, arg.Appliedby)
|
||||
var i Documentlabel
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Documentid,
|
||||
&i.Label,
|
||||
&i.Appliedat,
|
||||
&i.Appliedby,
|
||||
)
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const createLabel = `-- name: CreateLabel :one
|
||||
INSERT INTO labels (label, description)
|
||||
VALUES ($1, $2)
|
||||
RETURNING label, description
|
||||
`
|
||||
|
||||
type CreateLabelParams struct {
|
||||
Label string `db:"label"`
|
||||
Description string `db:"description"`
|
||||
}
|
||||
|
||||
// CreateLabel
|
||||
//
|
||||
// INSERT INTO labels (label, description)
|
||||
// VALUES ($1, $2)
|
||||
// RETURNING label, description
|
||||
func (q *Queries) CreateLabel(ctx context.Context, arg *CreateLabelParams) (*Label, error) {
|
||||
row := q.db.QueryRow(ctx, createLabel, arg.Label, arg.Description)
|
||||
var i Label
|
||||
err := row.Scan(&i.Label, &i.Description)
|
||||
return &i, err
|
||||
}
|
||||
|
||||
const getAllLabels = `-- name: GetAllLabels :many
|
||||
SELECT label, description FROM labels
|
||||
ORDER BY label
|
||||
`
|
||||
|
||||
// GetAllLabels
|
||||
//
|
||||
// SELECT label, description FROM labels
|
||||
// ORDER BY label
|
||||
func (q *Queries) GetAllLabels(ctx context.Context) ([]*Label, error) {
|
||||
rows, err := q.db.Query(ctx, getAllLabels)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []*Label{}
|
||||
for rows.Next() {
|
||||
var i Label
|
||||
if err := rows.Scan(&i.Label, &i.Description); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, &i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getDocumentLabelHistory = `-- name: GetDocumentLabelHistory :many
|
||||
SELECT dl.id, dl.documentid, dl.label, dl.appliedat, dl.appliedby, d.filename
|
||||
FROM documentLabels dl
|
||||
INNER JOIN documents d ON dl.documentId = d.id
|
||||
WHERE d.clientId = $1
|
||||
ORDER BY dl.appliedAt DESC
|
||||
LIMIT $2 OFFSET $3
|
||||
`
|
||||
|
||||
type GetDocumentLabelHistoryParams struct {
|
||||
Clientid string `db:"clientid"`
|
||||
Limit int64 `db:"limit"`
|
||||
Offset int64 `db:"offset"`
|
||||
}
|
||||
|
||||
type GetDocumentLabelHistoryRow struct {
|
||||
ID uuid.UUID `db:"id"`
|
||||
Documentid uuid.UUID `db:"documentid"`
|
||||
Label string `db:"label"`
|
||||
Appliedat pgtype.Timestamp `db:"appliedat"`
|
||||
Appliedby string `db:"appliedby"`
|
||||
Filename *string `db:"filename"`
|
||||
}
|
||||
|
||||
// GetDocumentLabelHistory
|
||||
//
|
||||
// SELECT dl.id, dl.documentid, dl.label, dl.appliedat, dl.appliedby, d.filename
|
||||
// FROM documentLabels dl
|
||||
// INNER JOIN documents d ON dl.documentId = d.id
|
||||
// WHERE d.clientId = $1
|
||||
// ORDER BY dl.appliedAt DESC
|
||||
// LIMIT $2 OFFSET $3
|
||||
func (q *Queries) GetDocumentLabelHistory(ctx context.Context, arg *GetDocumentLabelHistoryParams) ([]*GetDocumentLabelHistoryRow, error) {
|
||||
rows, err := q.db.Query(ctx, getDocumentLabelHistory, arg.Clientid, arg.Limit, arg.Offset)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []*GetDocumentLabelHistoryRow{}
|
||||
for rows.Next() {
|
||||
var i GetDocumentLabelHistoryRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Documentid,
|
||||
&i.Label,
|
||||
&i.Appliedat,
|
||||
&i.Appliedby,
|
||||
&i.Filename,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, &i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getDocumentLabels = `-- name: GetDocumentLabels :many
|
||||
SELECT id, documentid, label, appliedat, appliedby FROM documentLabels
|
||||
WHERE documentId = $1
|
||||
ORDER BY appliedAt DESC
|
||||
`
|
||||
|
||||
// GetDocumentLabels
|
||||
//
|
||||
// SELECT id, documentid, label, appliedat, appliedby FROM documentLabels
|
||||
// WHERE documentId = $1
|
||||
// ORDER BY appliedAt DESC
|
||||
func (q *Queries) GetDocumentLabels(ctx context.Context, documentid uuid.UUID) ([]*Documentlabel, error) {
|
||||
rows, err := q.db.Query(ctx, getDocumentLabels, documentid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []*Documentlabel{}
|
||||
for rows.Next() {
|
||||
var i Documentlabel
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Documentid,
|
||||
&i.Label,
|
||||
&i.Appliedat,
|
||||
&i.Appliedby,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, &i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getDocumentsByLabel = `-- name: GetDocumentsByLabel :many
|
||||
SELECT DISTINCT d.id, d.clientid, d.hash, d.batch_id, d.filename, d.folderid, d.originalpath
|
||||
FROM documents d
|
||||
INNER JOIN documentLabels dl ON d.id = dl.documentId
|
||||
WHERE d.clientId = $1 AND dl.label = $2
|
||||
ORDER BY d.id
|
||||
`
|
||||
|
||||
type GetDocumentsByLabelParams struct {
|
||||
Clientid string `db:"clientid"`
|
||||
Label string `db:"label"`
|
||||
}
|
||||
|
||||
// GetDocumentsByLabel
|
||||
//
|
||||
// SELECT DISTINCT d.id, d.clientid, d.hash, d.batch_id, d.filename, d.folderid, d.originalpath
|
||||
// FROM documents d
|
||||
// INNER JOIN documentLabels dl ON d.id = dl.documentId
|
||||
// WHERE d.clientId = $1 AND dl.label = $2
|
||||
// ORDER BY d.id
|
||||
func (q *Queries) GetDocumentsByLabel(ctx context.Context, arg *GetDocumentsByLabelParams) ([]*Document, error) {
|
||||
rows, err := q.db.Query(ctx, getDocumentsByLabel, arg.Clientid, arg.Label)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []*Document{}
|
||||
for rows.Next() {
|
||||
var i Document
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Clientid,
|
||||
&i.Hash,
|
||||
&i.BatchID,
|
||||
&i.Filename,
|
||||
&i.Folderid,
|
||||
&i.Originalpath,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, &i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getDocumentsByLabelAndFolder = `-- name: GetDocumentsByLabelAndFolder :many
|
||||
SELECT DISTINCT d.id, d.clientid, d.hash, d.batch_id, d.filename, d.folderid, d.originalpath
|
||||
FROM documents d
|
||||
INNER JOIN documentLabels dl ON d.id = dl.documentId
|
||||
WHERE d.folderId = $1 AND dl.label = $2
|
||||
ORDER BY d.id
|
||||
`
|
||||
|
||||
type GetDocumentsByLabelAndFolderParams struct {
|
||||
Folderid *uuid.UUID `db:"folderid"`
|
||||
Label string `db:"label"`
|
||||
}
|
||||
|
||||
// GetDocumentsByLabelAndFolder
|
||||
//
|
||||
// SELECT DISTINCT d.id, d.clientid, d.hash, d.batch_id, d.filename, d.folderid, d.originalpath
|
||||
// FROM documents d
|
||||
// INNER JOIN documentLabels dl ON d.id = dl.documentId
|
||||
// WHERE d.folderId = $1 AND dl.label = $2
|
||||
// ORDER BY d.id
|
||||
func (q *Queries) GetDocumentsByLabelAndFolder(ctx context.Context, arg *GetDocumentsByLabelAndFolderParams) ([]*Document, error) {
|
||||
rows, err := q.db.Query(ctx, getDocumentsByLabelAndFolder, arg.Folderid, arg.Label)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []*Document{}
|
||||
for rows.Next() {
|
||||
var i Document
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Clientid,
|
||||
&i.Hash,
|
||||
&i.BatchID,
|
||||
&i.Filename,
|
||||
&i.Folderid,
|
||||
&i.Originalpath,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, &i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getMostRecentLabel = `-- name: GetMostRecentLabel :one
|
||||
SELECT id, documentid, label, appliedat, appliedby FROM documentLabels
|
||||
WHERE documentId = $1 AND label = $2
|
||||
ORDER BY appliedAt DESC
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
type GetMostRecentLabelParams struct {
|
||||
Documentid uuid.UUID `db:"documentid"`
|
||||
Label string `db:"label"`
|
||||
}
|
||||
|
||||
// GetMostRecentLabel
|
||||
//
|
||||
// SELECT id, documentid, label, appliedat, appliedby FROM documentLabels
|
||||
// WHERE documentId = $1 AND label = $2
|
||||
// ORDER BY appliedAt DESC
|
||||
// LIMIT 1
|
||||
func (q *Queries) GetMostRecentLabel(ctx context.Context, arg *GetMostRecentLabelParams) (*Documentlabel, error) {
|
||||
row := q.db.QueryRow(ctx, getMostRecentLabel, arg.Documentid, arg.Label)
|
||||
var i Documentlabel
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Documentid,
|
||||
&i.Label,
|
||||
&i.Appliedat,
|
||||
&i.Appliedby,
|
||||
)
|
||||
return &i, err
|
||||
}
|
||||
Reference in New Issue
Block a user