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
+10 -58
View File
@@ -15,6 +15,9 @@ UPDATE clients SET name = $1 WHERE clientId = $2;
INSERT INTO clientCanSync (canSync, clientId) VALUES ($1, $2);
-- name: IsClientSynced :one
-- 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 (
-- Get all documents for this client
@@ -42,46 +45,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
@@ -89,22 +52,11 @@ 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;