|
|
|
@ -60,18 +60,12 @@ function makeFillQuery(withDependencies) {
|
|
|
|
|
SELECT item_id FROM tag_candidates
|
|
|
|
|
`
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
tasks AS NOT MATERIALIZED (
|
|
|
|
|
SELECT
|
|
|
|
|
:task AS task,
|
|
|
|
|
item_id
|
|
|
|
|
FROM full_candidates
|
|
|
|
|
WHERE NOT EXISTS (
|
|
|
|
|
SELECT item_id FROM srap_task_results AS results
|
|
|
|
|
WHERE
|
|
|
|
|
item_id = full_candidates.item_id
|
|
|
|
|
AND results.task = :task
|
|
|
|
|
AND results.task_version = :taskVersion
|
|
|
|
|
AND (
|
|
|
|
|
item_id,
|
|
|
|
|
is_successful,
|
|
|
|
|
(
|
|
|
|
|
results.is_successful = FALSE
|
|
|
|
|
OR (
|
|
|
|
|
results.is_successful = TRUE
|
|
|
|
@ -81,8 +75,19 @@ function makeFillQuery(withDependencies) {
|
|
|
|
|
OR results.expires_at IS NULL
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
) AS is_completed
|
|
|
|
|
FROM srap_task_results AS results
|
|
|
|
|
WHERE
|
|
|
|
|
results.task = :task
|
|
|
|
|
AND results.task_version = :taskVersion
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
SELECT
|
|
|
|
|
:task AS task,
|
|
|
|
|
full_candidates.item_id
|
|
|
|
|
FROM full_candidates
|
|
|
|
|
LEFT JOIN tasks ON full_candidates.item_id = tasks.item_id
|
|
|
|
|
WHERE tasks.is_completed IS NOT TRUE
|
|
|
|
|
ORDER BY tasks.is_successful NULLS FIRST
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|