|
|
|
@ -34,7 +34,10 @@ function makeFillQuery(withDependencies) {
|
|
|
|
|
WHERE
|
|
|
|
|
results.is_successful = TRUE
|
|
|
|
|
AND results.is_invalidated = FALSE
|
|
|
|
|
AND results.expires_at > NOW()
|
|
|
|
|
AND (
|
|
|
|
|
results.expires_at > NOW()
|
|
|
|
|
OR results.expires_at IS NULL
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
counts AS (
|
|
|
|
|
SELECT item_id, COUNT(task) AS count FROM satisfied GROUP BY item_id
|
|
|
|
@ -68,9 +71,17 @@ function makeFillQuery(withDependencies) {
|
|
|
|
|
item_id = full_candidates.item_id
|
|
|
|
|
AND results.task = :task
|
|
|
|
|
AND results.task_version = :taskVersion
|
|
|
|
|
AND results.is_successful = TRUE
|
|
|
|
|
AND (
|
|
|
|
|
results.is_successful = FALSE
|
|
|
|
|
OR (
|
|
|
|
|
results.is_successful = TRUE
|
|
|
|
|
AND results.is_invalidated = FALSE
|
|
|
|
|
AND results.expires_at > NOW()
|
|
|
|
|
AND (
|
|
|
|
|
results.expires_at > NOW()
|
|
|
|
|
OR results.expires_at IS NULL
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|