From 315714c6f6c58472be65c164f55bff313cfbcfe7 Mon Sep 17 00:00:00 2001 From: Craig Edmunds Date: Tue, 10 Dec 2024 13:42:51 +0000 Subject: [PATCH] CDMS-179 optimises Movements ByItemCount analytics for bigger datasets (#11) --- Btms.Analytics/MovementsAggregationService.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Btms.Analytics/MovementsAggregationService.cs b/Btms.Analytics/MovementsAggregationService.cs index ce31078..4009d96 100644 --- a/Btms.Analytics/MovementsAggregationService.cs +++ b/Btms.Analytics/MovementsAggregationService.cs @@ -98,16 +98,10 @@ public Task ByUniqueDocumentReferenceCount(DateTime from, .Distinct() .Count() }) - .GroupBy(g => g.Key.Linked); - + .Select(g => new { g.Key.Linked, g.Key.DocumentReferenceCount, MovementCount = g.Count() }); + var mongoResult = mongoQuery .Execute(logger) - .SelectMany(g => g.Select(l => new - { - Linked = g.Key, - DocumentReferenceCount = l.Key.DocumentReferenceCount, - MovementCount = l.Count() - })) .ToList(); var dictionary = mongoResult