Merged in feature/remove-query (pull request #201)
remove query from codebase part 1 * remove query * fix localstack run
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user