Created
June 26, 2018 00:34
-
-
Save atz/f2df4c950325d1f483264a42857830c5 to your computer and use it in GitHub Desktop.
query logic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Endpoint.which_need_archive_copy("bj102hs9687",2) | |
SELECT "endpoints".* FROM "endpoints" | |
INNER JOIN "endpoint_types" ON "endpoint_types"."id" = "endpoints"."endpoint_type_id" | |
INNER JOIN "endpoints_preservation_policies" ON "endpoints_preservation_policies"."endpoint_id" = "endpoints"."id" | |
INNER JOIN "preservation_policies" ON "preservation_policies"."id" = "endpoints_preservation_policies"."preservation_policy_id" | |
INNER JOIN "preserved_objects" ON "preserved_objects"."preservation_policy_id" = "preservation_policies"."id" | |
WHERE "endpoint_types"."endpoint_class" = $1 | |
AND "preserved_objects"."druid" = $2 | |
AND (NOT (EXISTS ( | |
SELECT "preserved_copies".* FROM "preserved_copies" | |
WHERE ("preserved_copies"."endpoint_id" = "endpoints"."id" | |
AND "preserved_copies"."version" = 2 | |
)))) [["endpoint_class", "archive"], ["druid", "bj102hs9687"]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment