Merged in feature/remove-query (pull request #201)
remove query from codebase part 1 * remove query * fix localstack run
This commit is contained in:
@@ -85,46 +85,6 @@ doc_text_entries AS (
|
||||
FROM
|
||||
doc_clean_entries d
|
||||
LEFT JOIN currentTextEntries cte ON cte.cleanId = d.clean_entry_id
|
||||
),
|
||||
required_results AS (
|
||||
-- All required document-query-version combinations
|
||||
SELECT
|
||||
dte.document_id,
|
||||
cqdt.queryId,
|
||||
cqdt.queryVersion,
|
||||
dte.text_entry_id
|
||||
FROM
|
||||
doc_text_entries dte
|
||||
JOIN collectorQueryDependencyTreeByClient($1) cqdt ON cqdt.clientId = dte.client_id
|
||||
where dte.clean_fail is null and dte.text_entry_id IS NOT NULL
|
||||
),
|
||||
existing_results AS (
|
||||
-- Valid results that exist
|
||||
SELECT
|
||||
rr.document_id AS document_id,
|
||||
r.queryId,
|
||||
r.id AS result_id
|
||||
FROM
|
||||
results r
|
||||
JOIN required_results rr ON
|
||||
r.queryId = rr.queryId AND
|
||||
r.queryVersion = rr.queryVersion AND
|
||||
r.textEntryId = rr.text_entry_id
|
||||
),
|
||||
missing_results AS (
|
||||
-- Find missing results
|
||||
SELECT rr.queryId
|
||||
FROM required_results rr
|
||||
LEFT JOIN existing_results er on er.queryId = rr.queryId
|
||||
WHERE er.result_id is null
|
||||
),
|
||||
dependency_check AS (
|
||||
-- Check for missing dependencies
|
||||
SELECT DISTINCT er.queryId, er.result_id, qcri.queryId, rd.resultId
|
||||
FROM existing_results er
|
||||
JOIN queryCurrentRequiredIds qcri on qcri.requiredQueryId = er.queryId
|
||||
LEFT JOIN resultDependencies rd on rd.requiredResultId = er.result_id
|
||||
WHERE rd.resultId is null
|
||||
)
|
||||
SELECT (
|
||||
-- No documents means client is synced
|
||||
@@ -132,28 +92,19 @@ SELECT (
|
||||
|
||||
OR
|
||||
|
||||
-- Documents with no text entries
|
||||
(
|
||||
NOT EXISTS (
|
||||
SELECT 1 FROM doc_text_entries
|
||||
where clean_entry_id is null or
|
||||
(clean_fail is null and text_entry_id is null)
|
||||
)
|
||||
|
||||
and
|
||||
|
||||
-- Documents with missing results
|
||||
NOT EXISTS (SELECT 1 FROM missing_results)
|
||||
|
||||
and
|
||||
|
||||
-- Documents with missing dependencies
|
||||
NOT EXISTS (SELECT 1 FROM dependency_check)
|
||||
)::bool
|
||||
-- All documents have completed processing (clean entry exists and either
|
||||
-- text entry exists or clean failed)
|
||||
NOT EXISTS (
|
||||
SELECT 1 FROM doc_text_entries
|
||||
where clean_entry_id is null or
|
||||
(clean_fail is null and text_entry_id is null)
|
||||
)
|
||||
)::bool as is_synced
|
||||
`
|
||||
|
||||
// IsClientSynced
|
||||
// Query functionality has been removed. A client is considered synced when
|
||||
// all documents have completed text extraction (or failed with explicit failure).
|
||||
// See remove_query_plan.md for details.
|
||||
//
|
||||
// WITH
|
||||
// docs AS (
|
||||
@@ -182,46 +133,6 @@ SELECT (
|
||||
// FROM
|
||||
// doc_clean_entries d
|
||||
// LEFT JOIN currentTextEntries cte ON cte.cleanId = d.clean_entry_id
|
||||
// ),
|
||||
// required_results AS (
|
||||
// -- All required document-query-version combinations
|
||||
// SELECT
|
||||
// dte.document_id,
|
||||
// cqdt.queryId,
|
||||
// cqdt.queryVersion,
|
||||
// dte.text_entry_id
|
||||
// FROM
|
||||
// doc_text_entries dte
|
||||
// JOIN collectorQueryDependencyTreeByClient($1) cqdt ON cqdt.clientId = dte.client_id
|
||||
// where dte.clean_fail is null and dte.text_entry_id IS NOT NULL
|
||||
// ),
|
||||
// existing_results AS (
|
||||
// -- Valid results that exist
|
||||
// SELECT
|
||||
// rr.document_id AS document_id,
|
||||
// r.queryId,
|
||||
// r.id AS result_id
|
||||
// FROM
|
||||
// results r
|
||||
// JOIN required_results rr ON
|
||||
// r.queryId = rr.queryId AND
|
||||
// r.queryVersion = rr.queryVersion AND
|
||||
// r.textEntryId = rr.text_entry_id
|
||||
// ),
|
||||
// missing_results AS (
|
||||
// -- Find missing results
|
||||
// SELECT rr.queryId
|
||||
// FROM required_results rr
|
||||
// LEFT JOIN existing_results er on er.queryId = rr.queryId
|
||||
// WHERE er.result_id is null
|
||||
// ),
|
||||
// dependency_check AS (
|
||||
// -- Check for missing dependencies
|
||||
// SELECT DISTINCT er.queryId, er.result_id, qcri.queryId, rd.resultId
|
||||
// FROM existing_results er
|
||||
// JOIN queryCurrentRequiredIds qcri on qcri.requiredQueryId = er.queryId
|
||||
// LEFT JOIN resultDependencies rd on rd.requiredResultId = er.result_id
|
||||
// WHERE rd.resultId is null
|
||||
// )
|
||||
// SELECT (
|
||||
// -- No documents means client is synced
|
||||
@@ -229,24 +140,13 @@ SELECT (
|
||||
//
|
||||
// OR
|
||||
//
|
||||
// -- Documents with no text entries
|
||||
// (
|
||||
// NOT EXISTS (
|
||||
// SELECT 1 FROM doc_text_entries
|
||||
// where clean_entry_id is null or
|
||||
// (clean_fail is null and text_entry_id is null)
|
||||
// )
|
||||
//
|
||||
// and
|
||||
//
|
||||
// -- Documents with missing results
|
||||
// NOT EXISTS (SELECT 1 FROM missing_results)
|
||||
//
|
||||
// and
|
||||
//
|
||||
// -- Documents with missing dependencies
|
||||
// NOT EXISTS (SELECT 1 FROM dependency_check)
|
||||
// )::bool
|
||||
// -- All documents have completed processing (clean entry exists and either
|
||||
// -- text entry exists or clean failed)
|
||||
// NOT EXISTS (
|
||||
// SELECT 1 FROM doc_text_entries
|
||||
// where clean_entry_id is null or
|
||||
// (clean_fail is null and text_entry_id is null)
|
||||
// )
|
||||
// )::bool as is_synced
|
||||
func (q *Queries) IsClientSynced(ctx context.Context, dollar_1 *string) (bool, error) {
|
||||
row := q.db.QueryRow(ctx, isClientSynced, dollar_1)
|
||||
|
||||
Reference in New Issue
Block a user