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