Skip to content

Commit 676d901

Browse files
committed
TD-937 Tweaks self assessment queries to use SQL date grouping
1 parent c256b5a commit 676d901

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

DigitalLearningSolutions.Data/DataServices/PlatformReportsDataService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class PlatformReportsDataService : IPlatformReportsDataService
4141
{
4242
private readonly IDbConnection connection;
4343
private readonly ILogger<PlatformReportsDataService> logger;
44-
private readonly string selectSelfAssessmentActivity = @"SELECT al.ActivityDate, al.Enrolled, al.Submitted | al.SignedOff AS Completed
44+
private readonly string selectSelfAssessmentActivity = @"SELECT Cast(al.ActivityDate As Date) As ActivityDate, SUM(CAST(al.Enrolled AS Int)) AS Enrolled, SUM(CAST((al.Submitted | al.SignedOff) AS Int)) AS Completed
4545
FROM ReportSelfAssessmentActivityLog AS al WITH (NOLOCK) INNER JOIN
4646
Centres AS ce WITH (NOLOCK) ON al.CentreID = ce.CentreID INNER JOIN
4747
SelfAssessments AS sa WITH (NOLOCK) ON sa.ID = al.SelfAssessmentID
@@ -116,7 +116,7 @@ public IEnumerable<SelfAssessmentActivity> GetSelfAssessmentActivity(
116116
{
117117
var whereClause = GetSelfAssessmentWhereClause(supervised);
118118
return connection.Query<SelfAssessmentActivity>(
119-
$@"{selectSelfAssessmentActivity} AND {whereClause}",
119+
$@"{selectSelfAssessmentActivity} AND {whereClause} GROUP BY Cast(al.ActivityDate As Date)",
120120
new
121121
{
122122
centreId,

DigitalLearningSolutions.Data/Models/PlatformReports/SelfAssessmentActivity.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
public class SelfAssessmentActivity
55
{
66
public DateTime ActivityDate { get; set; }
7-
public bool Enrolled { get; set; }
8-
public bool Completed { get; set; }
7+
public int Enrolled { get; set; }
8+
public int Completed { get; set; }
99
}
1010
}

DigitalLearningSolutions.Web/Services/PlatformReportService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ ReportInterval interval
9797
new DateTime(groupingOfLogs.Key),
9898
interval
9999
),
100-
groupingOfLogs.Count(activityLog => activityLog.Enrolled),
101-
groupingOfLogs.Count(activityLog => activityLog.Completed)
100+
groupingOfLogs.Sum(activityLog => activityLog.Enrolled),
101+
groupingOfLogs.Sum(activityLog => activityLog.Completed)
102102
)
103103
);
104104
}

0 commit comments

Comments
 (0)