Merged in feature/docresult (pull request #105)

Document Result Endpoint

* testing

* cleantesting

* progress

* query

* lint

* readme

* dockerclient

* api

* passtest

* tests

* test
This commit is contained in:
Michael McGuinness
2025-03-17 18:14:15 +00:00
parent f7c41c4ef3
commit 555b6d420b
105 changed files with 3276 additions and 2484 deletions
+19 -10
View File
@@ -24,17 +24,19 @@ doc_clean_entries as (
SELECT
d.id AS document_id,
d.clientId as client_id,
cte.id AS clean_entry_id
cte.id AS clean_entry_id,
cte.fail as clean_fail
FROM
docs d
LEFT JOIN currentCleanEntries cte ON cte.documentId = d.id
WHERE cte.id is null or cte.id is not null and cte.fail is null
),
doc_text_entries AS (
-- Documents with their current text entries
SELECT
d.document_id,
cte.id AS text_entry_id
cte.id AS text_entry_id,
d.clean_entry_id,
d.clean_fail
FROM
doc_clean_entries d
LEFT JOIN currentTextEntries cte ON cte.cleanEntryId = d.clean_entry_id
@@ -51,6 +53,7 @@ required_results AS (
JOIN collectorQueryDependencyTree cqdt ON cqdt.clientId = d.client_id
JOIN doc_text_entries dte ON dte.document_id = d.document_id
and dte.text_entry_id IS NOT NULL
where d.clean_fail is null
),
existing_results AS (
-- Valid results that exist
@@ -87,15 +90,21 @@ SELECT (
OR
-- Documents with no text entries
(NOT EXISTS (SELECT 1 FROM doc_text_entries WHERE text_entry_id IS NULL)
(
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
and
-- Documents with missing results
NOT EXISTS (SELECT 1 FROM missing_results)
-- Documents with missing results
NOT EXISTS (SELECT 1 FROM missing_results)
and
and
-- Documents with missing dependencies
NOT EXISTS (SELECT 1 FROM dependency_check))
-- Documents with missing dependencies
NOT EXISTS (SELECT 1 FROM dependency_check)
)::bool
)::bool as is_synced;