Merged in feature/textextraction (pull request #110)

Text Extraction

* bases

* go

* splitting

* structure

* movetoasync

* movetoasync

* settinguptrigger

* reorder

* storevent

* standardisepollingvalidation

* unittests

* fixlint

* fixlint

* awscfg

* generatesample

* followthrough

* tests

* clena

* store

* externalidcleanup

* clientid

* local

* baseunittests

* putobjecttests

* tests
This commit is contained in:
Michael McGuinness
2025-04-02 18:50:03 +00:00
parent e6a4cb3990
commit 81e7223560
226 changed files with 17283 additions and 2744 deletions
+21 -33
View File
@@ -34,8 +34,8 @@ INSERT INTO documents (clientId, hash) VALUES ($1, $2) RETURNING id
`
type CreateDocumentParams struct {
Clientid uuid.UUID `db:"clientid"`
Hash string `db:"hash"`
Clientid string `db:"clientid"`
Hash string `db:"hash"`
}
// CreateDocument
@@ -87,13 +87,12 @@ namedResults AS (
)
SELECT
d.id,
c.externalId AS clientId,
d.clientId,
d.hash,
COALESCE(jsonb_object_agg(r.name, r.value) FILTER (WHERE r.name IS NOT NULL), '{}') AS fields
FROM docs AS d
JOIN clients AS c ON c.id = d.clientId
LEFT JOIN namedResults AS r ON d.id = r.id
GROUP BY d.id, c.externalId, d.hash
GROUP BY d.id, d.clientId, d.hash
`
type GetDocumentExternalRow struct {
@@ -123,14 +122,13 @@ type GetDocumentExternalRow struct {
// )
// SELECT
// d.id,
// c.externalId AS clientId,
// d.clientId,
// d.hash,
// COALESCE(jsonb_object_agg(r.name, r.value) FILTER (WHERE r.name IS NOT NULL), '{}') AS fields
// FROM docs AS d
// JOIN clients AS c ON c.id = d.clientId
// LEFT JOIN namedResults AS r ON d.id = r.id
// GROUP BY d.id, c.externalId, d.hash
func (q *Queries) GetDocumentExternal(ctx context.Context, documentid *uuid.UUID) (*GetDocumentExternalRow, error) {
// GROUP BY d.id, d.clientId, d.hash
func (q *Queries) GetDocumentExternal(ctx context.Context, documentid uuid.UUID) (*GetDocumentExternalRow, error) {
row := q.db.QueryRow(ctx, getDocumentExternal, documentid)
var i GetDocumentExternalRow
err := row.Scan(
@@ -147,8 +145,8 @@ SELECT id FROM documents WHERE hash = $1 and clientId = $2
`
type GetDocumentIDByHashParams struct {
Hash string `db:"hash"`
Clientid uuid.UUID `db:"clientid"`
Hash string `db:"hash"`
Clientid string `db:"clientid"`
}
// GetDocumentIDByHash
@@ -180,9 +178,9 @@ SELECT id, totalCount FROM listDocumentIDs($1, $2, $3)
`
type ListDocumentIDsBatchParams struct {
Clientid uuid.UUID `db:"clientid"`
Batchsize int32 `db:"batchsize"`
Pageoffset int32 `db:"pageoffset"`
Clientid string `db:"clientid"`
Batchsize int32 `db:"batchsize"`
Pageoffset int32 `db:"pageoffset"`
}
type ListDocumentIDsBatchRow struct {
@@ -213,37 +211,27 @@ func (q *Queries) ListDocumentIDsBatch(ctx context.Context, arg *ListDocumentIDs
return items, nil
}
const listDocumentsByClientExternalId = `-- name: ListDocumentsByClientExternalId :many
WITH client as (
SELECT id from clients where externalId = $1
)
SELECT d.id, d.hash
from documents as d
JOIN client as c on d.clientId = c.id
const listDocumentsByClient = `-- name: ListDocumentsByClient :many
SELECT id, hash from documents where clientId = $1
`
type ListDocumentsByClientExternalIdRow struct {
type ListDocumentsByClientRow struct {
ID uuid.UUID `db:"id"`
Hash string `db:"hash"`
}
// ListDocumentsByClientExternalId
// ListDocumentsByClient
//
// WITH client as (
// SELECT id from clients where externalId = $1
// )
// SELECT d.id, d.hash
// from documents as d
// JOIN client as c on d.clientId = c.id
func (q *Queries) ListDocumentsByClientExternalId(ctx context.Context, clientid string) ([]*ListDocumentsByClientExternalIdRow, error) {
rows, err := q.db.Query(ctx, listDocumentsByClientExternalId, clientid)
// SELECT id, hash from documents where clientId = $1
func (q *Queries) ListDocumentsByClient(ctx context.Context, clientid string) ([]*ListDocumentsByClientRow, error) {
rows, err := q.db.Query(ctx, listDocumentsByClient, clientid)
if err != nil {
return nil, err
}
defer rows.Close()
items := []*ListDocumentsByClientExternalIdRow{}
items := []*ListDocumentsByClientRow{}
for rows.Next() {
var i ListDocumentsByClientExternalIdRow
var i ListDocumentsByClientRow
if err := rows.Scan(&i.ID, &i.Hash); err != nil {
return nil, err
}