From d6a53837ca63f90bfb2e5c10eb1dd3ce00e3bffb Mon Sep 17 00:00:00 2001 From: Duncan Carter Date: Fri, 8 Nov 2024 16:30:39 +0000 Subject: [PATCH] Remove unneeded join on worker training table as we don't need all training to determine if training cert exists for workplace or sub --- backend/server/models/establishment.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/server/models/establishment.js b/backend/server/models/establishment.js index 52aa885ff3..60233523e4 100644 --- a/backend/server/models/establishment.js +++ b/backend/server/models/establishment.js @@ -2400,8 +2400,7 @@ module.exports = function (sequelize, DataTypes) { ` SELECT 1 FROM cqc."Establishment" establishment INNER JOIN cqc."Worker" worker ON establishment."EstablishmentID" = worker."EstablishmentFK" - INNER JOIN cqc."WorkerTraining" workerTraining ON worker."ID" = workerTraining."WorkerFK" - INNER JOIN cqc."TrainingCertificates" trainingCertificate ON workerTraining."WorkerFK" = trainingCertificate."WorkerFK" + INNER JOIN cqc."TrainingCertificates" trainingCertificate ON worker."ID" = trainingCertificate."WorkerFK" WHERE establishment."Archived" = false AND worker."Archived" = false AND (establishment."EstablishmentID" = :workplaceId OR establishment."ParentID" = :workplaceId) LIMIT 1;