Created
February 10, 2023 06:38
-
-
Save jpike88/5bbb04f1691ffbf4478958702295a945 to your computer and use it in GitHub Desktop.
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
SELECT DISTINCT ON ("plant"."id") | |
"plant"."id" | |
FROM | |
"plant" | |
INNER JOIN "business" ON "business"."id" = "plant"."businessID" | |
LEFT JOIN "plant_schema_map" ON "plant_schema_map"."plantID" = "plant"."id" | |
AND "plant_schema_map"."active" in(TRUE) | |
LEFT JOIN "schema_clientGroup_map" ON "schema_clientGroup_map"."schemaID" = "plant_schema_map"."schemaID" | |
AND "plant_schema_map"."active" in(TRUE) | |
LEFT JOIN ( | |
SELECT | |
* | |
FROM | |
"business_clientGroup_map" | |
WHERE | |
"business_clientGroup_map"."businessID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e')) AS "business_clientGroup_map" ON "business_clientGroup_map"."clientGroupID" = "schema_clientGroup_map"."clientGroupID" | |
LEFT JOIN "clientGroup" ON "clientGroup"."id" = "schema_clientGroup_map"."clientGroupID" | |
LEFT JOIN "plant_sharing" ON "plant_sharing"."plantID" = "plant"."id" | |
LEFT JOIN "plant_assessment_map" ON "plant_assessment_map"."plantID" = "plant"."id" | |
LEFT JOIN "plant_assessment_step_map" ON "plant_assessment_step_map"."plantAssessmentID" = "plant_assessment_map"."id" | |
LEFT JOIN "plant_assessment_schema_status_map" ON "plant_assessment_schema_status_map"."plantID" = "plant"."id" | |
AND "plant_assessment_schema_status_map"."assessmentID" = "plant_assessment_map"."assessmentID" | |
AND "plant_assessment_schema_status_map"."schemaID" = "plant_schema_map"."schemaID" | |
LEFT JOIN "assessment" ON "assessment"."id" = "plant_assessment_map"."assessmentID" | |
LEFT JOIN "schema_assessment_map" ON "schema_assessment_map"."assessmentID" = "assessment"."id" | |
LEFT JOIN "plant_transfer_request" ON "plant_transfer_request"."plantID" = "plant"."id" | |
INNER JOIN "plant_specification_map" ON "plant_specification_map"."plantID" = "plant"."id" | |
WHERE | |
"business"."active" = TRUE | |
AND "plant"."active" = TRUE | |
AND "plant"."category" = 'plant' | |
and(("plant"."businessID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
or("business_clientGroup_map"."isClient" = TRUE AND 1 = 0 AND 1 = 0 | |
AND "business_clientGroup_map"."businessID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
or("business_clientGroup_map"."isPrinciple" = TRUE AND 1 = 0 AND 1 = 0 | |
AND "business_clientGroup_map"."businessID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e' | |
AND "business"."showToPrinciples" = TRUE) | |
or(("plant_sharing"."recipientID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e' | |
AND "plant_sharing"."pending" = FALSE) | |
or("plant_sharing"."recipientID" IS NOT NULL | |
AND "plant_sharing"."pending" = FALSE | |
AND "plant"."businessID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e'))) | |
AND "plant_schema_map"."awaitingApplicationReview" = FALSE | |
and(NOT EXISTS ( | |
SELECT | |
* FROM "schema_clientGroup_map" | |
LEFT JOIN "business_clientGroup_map" ON "business_clientGroup_map"."clientGroupID" = "schema_clientGroup_map"."clientGroupID" | |
WHERE | |
"schema_clientGroup_map"."schemaID" = "plant_schema_map"."schemaID" | |
AND "plant_schema_map"."plantID" = "plant"."id" | |
AND "business_clientGroup_map"."businessID" = "plant"."businessID" | |
AND "business_clientGroup_map"."isSuspended" = TRUE | |
AND "schema_clientGroup_map"."active" = TRUE | |
AND "business_clientGroup_map"."active" = TRUE | |
AND "plant_schema_map"."active" = TRUE)) | |
AND NOT EXISTS ( | |
SELECT | |
* | |
FROM | |
"schema_key_documents_map" | |
LEFT JOIN "key_documents" ON "key_documents"."id" = "schema_key_documents_map"."documentID" | |
LEFT JOIN "plant_key_documents_map" ON "plant_key_documents_map"."documentID" = "schema_key_documents_map"."documentID" | |
WHERE | |
"schema_key_documents_map"."schemaID" = "plant_schema_map"."schemaID" | |
AND "key_documents"."type" = 'plant' | |
AND "schema_key_documents_map"."active" = TRUE | |
AND "plant_key_documents_map"."expired" = TRUE | |
AND "plant_key_documents_map"."active" = TRUE | |
AND "plant_schema_map"."active" = TRUE | |
AND "plant_key_documents_map"."plantID" = "plant"."id" | |
AND "plant_schema_map"."plantID" = "plant"."id" | |
AND "schema_key_documents_map"."affectsComplianceStatus" = TRUE) | |
and(NOT EXISTS ( | |
SELECT | |
* FROM "schema_key_documents_map" | |
LEFT JOIN "key_documents" ON "key_documents"."id" = "schema_key_documents_map"."documentID" | |
LEFT JOIN "plant_key_documents_map" ON "plant_key_documents_map"."documentID" = "schema_key_documents_map"."documentID" | |
WHERE | |
"schema_key_documents_map"."schemaID" = "plant_schema_map"."schemaID" | |
AND "key_documents"."type" = 'plant' | |
AND "schema_key_documents_map"."active" = TRUE | |
AND "plant_schema_map"."active" = TRUE | |
AND "schema_key_documents_map"."affectsComplianceStatus" = TRUE | |
AND "plant_schema_map"."plantID" = "plant"."id" | |
AND "plant_key_documents_map"."plantID" IS NULL)) | |
and("plant_schema_map"."verificationDateDue" IS NULL | |
OR "plant_schema_map"."verificationDateDue" > 1676009547 | |
OR "plant_schema_map"."requiresVerification" = FALSE) | |
and("plant_schema_map"."lastFailedVerificationFormID" IS NULL | |
OR "plant_schema_map"."verificationReviewFormID" IS NOT NULL | |
OR "plant_schema_map"."requiresVerification" = FALSE) | |
AND "plant_schema_map"."flagged" = FALSE | |
AND "plant"."id" NOT in( | |
SELECT | |
"plant"."id" FROM "plant" | |
INNER JOIN "plant_schema_map" ON "plant_schema_map"."plantID" = "plant"."id" | |
AND "plant_schema_map"."active" in(TRUE) | |
INNER JOIN "schema_clientGroup_map" ON "schema_clientGroup_map"."schemaID" = "plant_schema_map"."schemaID" | |
AND "plant_schema_map"."active" in(TRUE) | |
INNER JOIN "business" ON "business"."id" = "plant"."businessID" | |
INNER JOIN ( | |
SELECT | |
* FROM "business_clientGroup_map" | |
WHERE | |
"business_clientGroup_map"."businessID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e')) AS "business_clientGroup_map" ON "business_clientGroup_map"."clientGroupID" = "schema_clientGroup_map"."clientGroupID" | |
INNER JOIN "schema_assessment_map" ON "schema_assessment_map"."schemaID" = "schema_clientGroup_map"."schemaID" | |
INNER JOIN "plant_assessment_map" ON "plant_assessment_map"."plantID" = "plant"."id" | |
AND "plant_assessment_map"."assessmentID" = "schema_assessment_map"."assessmentID" | |
INNER JOIN "plant_assessment_schema_status_map" ON "plant_assessment_schema_status_map"."plantID" = "plant"."id" | |
AND "plant_assessment_schema_status_map"."assessmentID" = "schema_assessment_map"."assessmentID" | |
AND "plant_assessment_schema_status_map"."schemaID" = "plant_schema_map"."schemaID" | |
INNER JOIN "plant_assessment_step_map" ON "plant_assessment_step_map"."plantAssessmentID" = "plant_assessment_map"."id" | |
INNER JOIN "assessment" ON "assessment"."id" = "plant_assessment_map"."assessmentID" | |
WHERE | |
"plant_assessment_map"."active" = TRUE | |
AND "schema_assessment_map"."active" = TRUE | |
AND "assessment"."active" = TRUE | |
AND "plant_schema_map"."awaitingApplicationReview" = FALSE | |
AND "schema_clientGroup_map"."clientGroupID" in(1, 3, 16, 20, 23, 34) | |
and(("business_clientGroup_map"."isClient" = TRUE | |
AND "business_clientGroup_map"."businessID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
AND 1 = 0 | |
AND "plant_assessment_schema_status_map"."schemaID" in( | |
SELECT | |
"schema_clientGroup_map"."schemaID" FROM "schema_clientGroup_map" | |
WHERE | |
1 = 0 | |
AND "schema_clientGroup_map"."active" = TRUE)) | |
or("plant"."businessID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e')) | |
or("plant_assessment_map"."assessorID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
AND "business"."locked" = FALSE)) | |
and("plant_assessment_schema_status_map"."failed" = TRUE | |
OR "plant_assessment_step_map"."dateDue" = 1676009538)) | |
and((("plant"."businessID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e')) | |
or("business_clientGroup_map"."isClient" = TRUE AND 1 = 0 AND 1 = 0 | |
AND "business_clientGroup_map"."businessID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
or("business_clientGroup_map"."isPrinciple" = TRUE AND 1 = 0 AND 1 = 0 | |
AND "business_clientGroup_map"."businessID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e' | |
AND "business"."showToPrinciples" = TRUE) | |
OR "plant"."id" in( | |
SELECT | |
"plant"."id" FROM "plant" | |
INNER JOIN "plant_schema_map" ON "plant_schema_map"."plantID" = "plant"."id" | |
AND "plant_schema_map"."active" in(TRUE) | |
INNER JOIN "schema_clientGroup_map" ON "schema_clientGroup_map"."schemaID" = "plant_schema_map"."schemaID" | |
AND "plant_schema_map"."active" in(TRUE) | |
INNER JOIN "business" ON "business"."id" = "plant"."businessID" | |
INNER JOIN ( | |
SELECT | |
* FROM "business_clientGroup_map" | |
WHERE | |
"business_clientGroup_map"."businessID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e')) AS "business_clientGroup_map" ON "business_clientGroup_map"."clientGroupID" = "schema_clientGroup_map"."clientGroupID" | |
INNER JOIN "schema_assessment_map" ON "schema_assessment_map"."schemaID" = "schema_clientGroup_map"."schemaID" | |
INNER JOIN "plant_assessment_map" ON "plant_assessment_map"."plantID" = "plant"."id" | |
AND "plant_assessment_map"."assessmentID" = "schema_assessment_map"."assessmentID" | |
INNER JOIN "plant_assessment_schema_status_map" ON "plant_assessment_schema_status_map"."plantID" = "plant"."id" | |
AND "plant_assessment_schema_status_map"."assessmentID" = "schema_assessment_map"."assessmentID" | |
AND "plant_assessment_schema_status_map"."schemaID" = "plant_schema_map"."schemaID" | |
INNER JOIN "plant_assessment_step_map" ON "plant_assessment_step_map"."plantAssessmentID" = "plant_assessment_map"."id" | |
INNER JOIN "assessment" ON "assessment"."id" = "plant_assessment_map"."assessmentID" | |
WHERE | |
"plant_assessment_map"."active" = TRUE | |
AND "schema_assessment_map"."active" = TRUE | |
AND "assessment"."active" = TRUE | |
AND "plant_schema_map"."awaitingApplicationReview" = FALSE | |
AND "schema_clientGroup_map"."clientGroupID" in(1, 3, 16, 20, 23, 34) | |
and(("business_clientGroup_map"."isClient" = TRUE | |
AND "business_clientGroup_map"."businessID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
AND 1 = 0 | |
AND "plant_assessment_schema_status_map"."schemaID" in( | |
SELECT | |
"schema_clientGroup_map"."schemaID" FROM "schema_clientGroup_map" | |
WHERE | |
1 = 0 | |
AND "schema_clientGroup_map"."active" = TRUE)) | |
or("plant"."businessID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e')) | |
or("plant_assessment_map"."assessorID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
AND "business"."locked" = FALSE)) | |
and("plant_assessment_map"."assessorID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e' | |
AND "business"."locked" = FALSE)) | |
or(("plant_sharing"."recipientID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e' | |
AND "plant_sharing"."pending" = FALSE) | |
or("plant_transfer_request"."recipientID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
or("plant_sharing"."recipientID" IS NOT NULL | |
AND "plant_sharing"."pending" = FALSE | |
AND "plant"."businessID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e'))) | |
and("plant"."businessID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
OR EXISTS ( | |
SELECT | |
* FROM "plant_sharing" | |
WHERE | |
"plant_sharing"."plantID" = "plant"."id" | |
AND "plant_sharing"."recipientID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
AND "plant_sharing"."pending" = FALSE)) | |
AND "plant_schema_map"."schemaID" in(33) | |
and("plant_specification_map"."specificationID" = 107 | |
and("plant_specification_map"."value" = '8675 - Hi Rail EWP Telehandler Slew Type 21mtrs platform height' | |
OR "plant_specification_map"."valueNoSpaces" = '8675 - Hi Rail EWP Telehandler Slew Type 21mtrs platform height'))SELECT DISTINCT ON ("plant"."id") | |
"plant"."id" | |
FROM | |
"plant" | |
INNER JOIN "business" ON "business"."id" = "plant"."businessID" | |
LEFT JOIN "plant_schema_map" ON "plant_schema_map"."plantID" = "plant"."id" | |
AND "plant_schema_map"."active" in(TRUE) | |
LEFT JOIN "schema_clientGroup_map" ON "schema_clientGroup_map"."schemaID" = "plant_schema_map"."schemaID" | |
AND "plant_schema_map"."active" in(TRUE) | |
LEFT JOIN ( | |
SELECT | |
* | |
FROM | |
"business_clientGroup_map" | |
WHERE | |
"business_clientGroup_map"."businessID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e')) AS "business_clientGroup_map" ON "business_clientGroup_map"."clientGroupID" = "schema_clientGroup_map"."clientGroupID" | |
LEFT JOIN "clientGroup" ON "clientGroup"."id" = "schema_clientGroup_map"."clientGroupID" | |
LEFT JOIN "plant_sharing" ON "plant_sharing"."plantID" = "plant"."id" | |
LEFT JOIN "plant_assessment_map" ON "plant_assessment_map"."plantID" = "plant"."id" | |
LEFT JOIN "plant_assessment_step_map" ON "plant_assessment_step_map"."plantAssessmentID" = "plant_assessment_map"."id" | |
LEFT JOIN "plant_assessment_schema_status_map" ON "plant_assessment_schema_status_map"."plantID" = "plant"."id" | |
AND "plant_assessment_schema_status_map"."assessmentID" = "plant_assessment_map"."assessmentID" | |
AND "plant_assessment_schema_status_map"."schemaID" = "plant_schema_map"."schemaID" | |
LEFT JOIN "assessment" ON "assessment"."id" = "plant_assessment_map"."assessmentID" | |
LEFT JOIN "schema_assessment_map" ON "schema_assessment_map"."assessmentID" = "assessment"."id" | |
LEFT JOIN "plant_transfer_request" ON "plant_transfer_request"."plantID" = "plant"."id" | |
INNER JOIN "plant_specification_map" ON "plant_specification_map"."plantID" = "plant"."id" | |
WHERE | |
"business"."active" = TRUE | |
AND "plant"."active" = TRUE | |
AND "plant"."category" = 'plant' | |
and(("plant"."businessID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
or("business_clientGroup_map"."isClient" = TRUE AND 1 = 0 AND 1 = 0 | |
AND "business_clientGroup_map"."businessID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
or("business_clientGroup_map"."isPrinciple" = TRUE AND 1 = 0 AND 1 = 0 | |
AND "business_clientGroup_map"."businessID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e' | |
AND "business"."showToPrinciples" = TRUE) | |
or(("plant_sharing"."recipientID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e' | |
AND "plant_sharing"."pending" = FALSE) | |
or("plant_sharing"."recipientID" IS NOT NULL | |
AND "plant_sharing"."pending" = FALSE | |
AND "plant"."businessID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e'))) | |
AND "plant_schema_map"."awaitingApplicationReview" = FALSE | |
and(NOT EXISTS ( | |
SELECT | |
* FROM "schema_clientGroup_map" | |
LEFT JOIN "business_clientGroup_map" ON "business_clientGroup_map"."clientGroupID" = "schema_clientGroup_map"."clientGroupID" | |
WHERE | |
"schema_clientGroup_map"."schemaID" = "plant_schema_map"."schemaID" | |
AND "plant_schema_map"."plantID" = "plant"."id" | |
AND "business_clientGroup_map"."businessID" = "plant"."businessID" | |
AND "business_clientGroup_map"."isSuspended" = TRUE | |
AND "schema_clientGroup_map"."active" = TRUE | |
AND "business_clientGroup_map"."active" = TRUE | |
AND "plant_schema_map"."active" = TRUE)) | |
AND NOT EXISTS ( | |
SELECT | |
* | |
FROM | |
"schema_key_documents_map" | |
LEFT JOIN "key_documents" ON "key_documents"."id" = "schema_key_documents_map"."documentID" | |
LEFT JOIN "plant_key_documents_map" ON "plant_key_documents_map"."documentID" = "schema_key_documents_map"."documentID" | |
WHERE | |
"schema_key_documents_map"."schemaID" = "plant_schema_map"."schemaID" | |
AND "key_documents"."type" = 'plant' | |
AND "schema_key_documents_map"."active" = TRUE | |
AND "plant_key_documents_map"."expired" = TRUE | |
AND "plant_key_documents_map"."active" = TRUE | |
AND "plant_schema_map"."active" = TRUE | |
AND "plant_key_documents_map"."plantID" = "plant"."id" | |
AND "plant_schema_map"."plantID" = "plant"."id" | |
AND "schema_key_documents_map"."affectsComplianceStatus" = TRUE) | |
and(NOT EXISTS ( | |
SELECT | |
* FROM "schema_key_documents_map" | |
LEFT JOIN "key_documents" ON "key_documents"."id" = "schema_key_documents_map"."documentID" | |
LEFT JOIN "plant_key_documents_map" ON "plant_key_documents_map"."documentID" = "schema_key_documents_map"."documentID" | |
WHERE | |
"schema_key_documents_map"."schemaID" = "plant_schema_map"."schemaID" | |
AND "key_documents"."type" = 'plant' | |
AND "schema_key_documents_map"."active" = TRUE | |
AND "plant_schema_map"."active" = TRUE | |
AND "schema_key_documents_map"."affectsComplianceStatus" = TRUE | |
AND "plant_schema_map"."plantID" = "plant"."id" | |
AND "plant_key_documents_map"."plantID" IS NULL)) | |
and("plant_schema_map"."verificationDateDue" IS NULL | |
OR "plant_schema_map"."verificationDateDue" > 1676009547 | |
OR "plant_schema_map"."requiresVerification" = FALSE) | |
and("plant_schema_map"."lastFailedVerificationFormID" IS NULL | |
OR "plant_schema_map"."verificationReviewFormID" IS NOT NULL | |
OR "plant_schema_map"."requiresVerification" = FALSE) | |
AND "plant_schema_map"."flagged" = FALSE | |
AND "plant"."id" NOT in( | |
SELECT | |
"plant"."id" FROM "plant" | |
INNER JOIN "plant_schema_map" ON "plant_schema_map"."plantID" = "plant"."id" | |
AND "plant_schema_map"."active" in(TRUE) | |
INNER JOIN "schema_clientGroup_map" ON "schema_clientGroup_map"."schemaID" = "plant_schema_map"."schemaID" | |
AND "plant_schema_map"."active" in(TRUE) | |
INNER JOIN "business" ON "business"."id" = "plant"."businessID" | |
INNER JOIN ( | |
SELECT | |
* FROM "business_clientGroup_map" | |
WHERE | |
"business_clientGroup_map"."businessID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e')) AS "business_clientGroup_map" ON "business_clientGroup_map"."clientGroupID" = "schema_clientGroup_map"."clientGroupID" | |
INNER JOIN "schema_assessment_map" ON "schema_assessment_map"."schemaID" = "schema_clientGroup_map"."schemaID" | |
INNER JOIN "plant_assessment_map" ON "plant_assessment_map"."plantID" = "plant"."id" | |
AND "plant_assessment_map"."assessmentID" = "schema_assessment_map"."assessmentID" | |
INNER JOIN "plant_assessment_schema_status_map" ON "plant_assessment_schema_status_map"."plantID" = "plant"."id" | |
AND "plant_assessment_schema_status_map"."assessmentID" = "schema_assessment_map"."assessmentID" | |
AND "plant_assessment_schema_status_map"."schemaID" = "plant_schema_map"."schemaID" | |
INNER JOIN "plant_assessment_step_map" ON "plant_assessment_step_map"."plantAssessmentID" = "plant_assessment_map"."id" | |
INNER JOIN "assessment" ON "assessment"."id" = "plant_assessment_map"."assessmentID" | |
WHERE | |
"plant_assessment_map"."active" = TRUE | |
AND "schema_assessment_map"."active" = TRUE | |
AND "assessment"."active" = TRUE | |
AND "plant_schema_map"."awaitingApplicationReview" = FALSE | |
AND "schema_clientGroup_map"."clientGroupID" in(1, 3, 16, 20, 23, 34) | |
and(("business_clientGroup_map"."isClient" = TRUE | |
AND "business_clientGroup_map"."businessID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
AND 1 = 0 | |
AND "plant_assessment_schema_status_map"."schemaID" in( | |
SELECT | |
"schema_clientGroup_map"."schemaID" FROM "schema_clientGroup_map" | |
WHERE | |
1 = 0 | |
AND "schema_clientGroup_map"."active" = TRUE)) | |
or("plant"."businessID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e')) | |
or("plant_assessment_map"."assessorID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
AND "business"."locked" = FALSE)) | |
and("plant_assessment_schema_status_map"."failed" = TRUE | |
OR "plant_assessment_step_map"."dateDue" = 1676009538)) | |
and((("plant"."businessID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e')) | |
or("business_clientGroup_map"."isClient" = TRUE AND 1 = 0 AND 1 = 0 | |
AND "business_clientGroup_map"."businessID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
or("business_clientGroup_map"."isPrinciple" = TRUE AND 1 = 0 AND 1 = 0 | |
AND "business_clientGroup_map"."businessID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e' | |
AND "business"."showToPrinciples" = TRUE) | |
OR "plant"."id" in( | |
SELECT | |
"plant"."id" FROM "plant" | |
INNER JOIN "plant_schema_map" ON "plant_schema_map"."plantID" = "plant"."id" | |
AND "plant_schema_map"."active" in(TRUE) | |
INNER JOIN "schema_clientGroup_map" ON "schema_clientGroup_map"."schemaID" = "plant_schema_map"."schemaID" | |
AND "plant_schema_map"."active" in(TRUE) | |
INNER JOIN "business" ON "business"."id" = "plant"."businessID" | |
INNER JOIN ( | |
SELECT | |
* FROM "business_clientGroup_map" | |
WHERE | |
"business_clientGroup_map"."businessID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e')) AS "business_clientGroup_map" ON "business_clientGroup_map"."clientGroupID" = "schema_clientGroup_map"."clientGroupID" | |
INNER JOIN "schema_assessment_map" ON "schema_assessment_map"."schemaID" = "schema_clientGroup_map"."schemaID" | |
INNER JOIN "plant_assessment_map" ON "plant_assessment_map"."plantID" = "plant"."id" | |
AND "plant_assessment_map"."assessmentID" = "schema_assessment_map"."assessmentID" | |
INNER JOIN "plant_assessment_schema_status_map" ON "plant_assessment_schema_status_map"."plantID" = "plant"."id" | |
AND "plant_assessment_schema_status_map"."assessmentID" = "schema_assessment_map"."assessmentID" | |
AND "plant_assessment_schema_status_map"."schemaID" = "plant_schema_map"."schemaID" | |
INNER JOIN "plant_assessment_step_map" ON "plant_assessment_step_map"."plantAssessmentID" = "plant_assessment_map"."id" | |
INNER JOIN "assessment" ON "assessment"."id" = "plant_assessment_map"."assessmentID" | |
WHERE | |
"plant_assessment_map"."active" = TRUE | |
AND "schema_assessment_map"."active" = TRUE | |
AND "assessment"."active" = TRUE | |
AND "plant_schema_map"."awaitingApplicationReview" = FALSE | |
AND "schema_clientGroup_map"."clientGroupID" in(1, 3, 16, 20, 23, 34) | |
and(("business_clientGroup_map"."isClient" = TRUE | |
AND "business_clientGroup_map"."businessID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
AND 1 = 0 | |
AND "plant_assessment_schema_status_map"."schemaID" in( | |
SELECT | |
"schema_clientGroup_map"."schemaID" FROM "schema_clientGroup_map" | |
WHERE | |
1 = 0 | |
AND "schema_clientGroup_map"."active" = TRUE)) | |
or("plant"."businessID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e')) | |
or("plant_assessment_map"."assessorID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
AND "business"."locked" = FALSE)) | |
and("plant_assessment_map"."assessorID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e' | |
AND "business"."locked" = FALSE)) | |
or(("plant_sharing"."recipientID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e' | |
AND "plant_sharing"."pending" = FALSE) | |
or("plant_transfer_request"."recipientID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
or("plant_sharing"."recipientID" IS NOT NULL | |
AND "plant_sharing"."pending" = FALSE | |
AND "plant"."businessID" = '996f5920-2ab3-45d4-8137-ba2036c4b41e'))) | |
and("plant"."businessID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
OR EXISTS ( | |
SELECT | |
* FROM "plant_sharing" | |
WHERE | |
"plant_sharing"."plantID" = "plant"."id" | |
AND "plant_sharing"."recipientID" in('996f5920-2ab3-45d4-8137-ba2036c4b41e') | |
AND "plant_sharing"."pending" = FALSE)) | |
AND "plant_schema_map"."schemaID" in(33) | |
and("plant_specification_map"."specificationID" = 107 | |
and("plant_specification_map"."value" = '8675 - Hi Rail EWP Telehandler Slew Type 21mtrs platform height' | |
OR "plant_specification_map"."valueNoSpaces" = '8675 - Hi Rail EWP Telehandler Slew Type 21mtrs platform height')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment