From 15214bf587dc9864961d558cc9c43583e02dcbb3 Mon Sep 17 00:00:00 2001 From: kevwhitt-hee Date: Tue, 24 Jun 2025 17:08:57 +0100 Subject: [PATCH 1/2] TD-5709 fixes subquery returns multiple results error --- .../DataServices/FrameworkDataService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs b/DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs index b6c03802f5..8d904282bd 100644 --- a/DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs +++ b/DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs @@ -301,7 +301,7 @@ FROM FrameworkCollaborators fc AND aa3.UserID = (SELECT aa4.UserID FROM AdminAccounts aa4 WHERE aa4.ID = @adminId)) > 0 THEN 1 ELSE 0 END AS UserRole, - (SELECT fwr.ID + (SELECT TOP(1) fwr.ID FROM FrameworkCollaborators fc INNER JOIN AdminAccounts aa3 ON fc.AdminID = aa3.ID LEFT OUTER JOIN FrameworkReviews AS fwr ON fc.ID = fwr.FrameworkCollaboratorID AND fwr.Archived IS NULL AND fwr.ReviewComplete IS NULL From 271f4d1860f5b52e92a04a36115c84241a00c0d2 Mon Sep 17 00:00:00 2001 From: Rohit Shrivastava Date: Tue, 8 Jul 2025 16:17:54 +0100 Subject: [PATCH 2/2] TD-5709 Added where clause to limit the results to active admin records --- .../DataServices/FrameworkDataService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs b/DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs index 8d904282bd..07ab221315 100644 --- a/DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs +++ b/DigitalLearningSolutions.Data/DataServices/FrameworkDataService.cs @@ -306,7 +306,8 @@ FROM FrameworkCollaborators fc INNER JOIN AdminAccounts aa3 ON fc.AdminID = aa3.ID LEFT OUTER JOIN FrameworkReviews AS fwr ON fc.ID = fwr.FrameworkCollaboratorID AND fwr.Archived IS NULL AND fwr.ReviewComplete IS NULL WHERE fc.FrameworkID = fw.ID AND fc.IsDeleted = 0 - AND aa3.UserID = (SELECT aa4.UserID FROM AdminAccounts aa4 WHERE aa4.ID = @adminId)) AS FrameworkReviewID"; + AND aa3.UserID = (SELECT aa4.UserID FROM AdminAccounts aa4 WHERE aa4.ID = @adminId) + AND aa3.Active = 1 ORDER BY fwr.ID DESC) AS FrameworkReviewID"; private const string BrandedFrameworkFields = @",(SELECT BrandName