Merged in feature/remove-query (pull request #201)

remove query from codebase part 1

* remove query

* fix localstack run
This commit is contained in:
Jay Brown
2026-01-14 17:59:04 +00:00
parent ebf47c6013
commit 0ddae4f91e
167 changed files with 1059 additions and 20641 deletions
+12 -54
View File
@@ -167,74 +167,32 @@ func (q *Queries) GetDocumentEntry(ctx context.Context, documentid uuid.UUID) (*
}
const getDocumentExternal = `-- name: GetDocumentExternal :one
WITH
docs AS (
SELECT id, hash, clientId
FROM documents
WHERE id = $1
),
namedResults AS (
SELECT
q.name,
dd.id,
d.value
FROM currentCollectorQueries AS q
JOIN docs as dd on dd.clientId = q.clientId
LEFT JOIN listValidDocumentResults($1) AS d
ON d.queryId = q.queryId and q.name is not null
)
SELECT
d.id,
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
LEFT JOIN namedResults AS r ON d.id = r.id
GROUP BY d.id, d.clientId, d.hash
id,
clientId,
hash
FROM documents
WHERE id = $1
`
type GetDocumentExternalRow struct {
ID uuid.UUID `db:"id"`
Clientid string `db:"clientid"`
Hash string `db:"hash"`
Fields []byte `db:"fields"`
}
// GetDocumentExternal
// Query functionality has been removed. See remove_query_plan.md for details.
//
// WITH
// docs AS (
// SELECT id, hash, clientId
// FROM documents
// WHERE id = $1
// ),
// namedResults AS (
// SELECT
// q.name,
// dd.id,
// d.value
// FROM currentCollectorQueries AS q
// JOIN docs as dd on dd.clientId = q.clientId
// LEFT JOIN listValidDocumentResults($1) AS d
// ON d.queryId = q.queryId and q.name is not null
// )
// SELECT
// d.id,
// 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
// LEFT JOIN namedResults AS r ON d.id = r.id
// GROUP BY d.id, d.clientId, d.hash
// id,
// clientId,
// hash
// FROM documents
// WHERE id = $1
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(
&i.ID,
&i.Clientid,
&i.Hash,
&i.Fields,
)
err := row.Scan(&i.ID, &i.Clientid, &i.Hash)
return &i, err
}