diff --git a/Btms.Analytics.Tests/MovementsByArrivalDateTests.cs b/Btms.Analytics.Tests/MovementsByArrivalDateTests.cs deleted file mode 100644 index 3e36d79..0000000 --- a/Btms.Analytics.Tests/MovementsByArrivalDateTests.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Btms.Common.Extensions; -using Btms.Model.Extensions; -using FluentAssertions; -using Xunit; -using Xunit.Abstractions; - -using Btms.Analytics.Tests.Fixtures; - -namespace Btms.Analytics.Tests; - -[Collection(nameof(BasicSampleDataTestCollection))] -public class MovementsByArrivalDateTests( - BasicSampleDataTestFixture basicSampleDataTestFixture, - ITestOutputHelper testOutputHelper) { - - [Fact] - public async Task WhenCalledNext72Hours_ReturnExpectedAggregation() - { - - var result = (await basicSampleDataTestFixture.MovementsAggregationService - .ByArrival(DateTime.Now.CurrentHour(), DateTime.Now.CurrentHour().AddDays(3), AggregationPeriod.Hour)) - .ToList(); - - testOutputHelper.WriteLine(result.ToJsonString()); - - result.Select(r => r.Name).Order().Should().Equal("Linked", "Not Linked"); - - result[0].Periods[0].Period.Should().BeOnOrAfter(DateTime.Today); - result[0].Periods.Count.Should().Be(72); - } - - [Fact] - public async Task WhenCalledNextMonth_ReturnExpectedAggregation() - { - var result = (await basicSampleDataTestFixture.MovementsAggregationService - .ByArrival(DateTime.Today, DateTime.Today.MonthLater())) - .ToList(); - - testOutputHelper.WriteLine(result.ToJsonString()); - - result.Count.Should().Be(2); - - result[0].Name.Should().Be("Linked"); - result[0].Periods[0].Period.Should().BeOnOrAfter(DateTime.Today); - result[0].Periods.Count.Should().Be(DateTime.Today.DaysUntilMonthLater()); - - result[1].Name.Should().Be("Not Linked"); - } -} \ No newline at end of file diff --git a/Btms.Analytics/IMovementsAggregationService.cs b/Btms.Analytics/IMovementsAggregationService.cs index a3324f0..f9635ae 100644 --- a/Btms.Analytics/IMovementsAggregationService.cs +++ b/Btms.Analytics/IMovementsAggregationService.cs @@ -3,7 +3,6 @@ namespace Btms.Analytics; public interface IMovementsAggregationService { public Task ByCreated(DateTime from, DateTime to, AggregationPeriod aggregateBy = AggregationPeriod.Day); - public Task ByArrival(DateTime from, DateTime to, AggregationPeriod aggregateBy = AggregationPeriod.Day); public Task ByStatus(DateTime from, DateTime to); public Task ByItemCount(DateTime from, DateTime to); public Task ByUniqueDocumentReferenceCount(DateTime from, DateTime to); diff --git a/Btms.Analytics/MovementsAggregationService.cs b/Btms.Analytics/MovementsAggregationService.cs index ec2799e..672fb26 100644 --- a/Btms.Analytics/MovementsAggregationService.cs +++ b/Btms.Analytics/MovementsAggregationService.cs @@ -38,25 +38,6 @@ public Task ByCreated(DateTime from, DateTime to, return Aggregate(dateRange, CreateDatasetName, matchFilter, "$createdSource", aggregateBy); } - /// - /// Aggregates movements by arrival date and returns counts by date period. Could be refactored to use a generic/interface in time - /// - /// Time period to search from (inclusive) - /// Time period to search to (exclusive) - /// Aggregate by day/hour - /// - public Task ByArrival(DateTime from, DateTime to, AggregationPeriod aggregateBy = AggregationPeriod.Day) - { - var dateRange = AnalyticsHelpers.CreateDateRange(from, to, aggregateBy); - - Expression> matchFilter = n => - n.CreatedSource >= from && n.CreatedSource < to; - - string CreateDatasetName(BsonDocument b) => AnalyticsHelpers.GetLinkedName(b["_id"]["linked"].ToBoolean()); - - return Aggregate(dateRange, CreateDatasetName, matchFilter, "$arrivesAt", aggregateBy); - } - public Task ByStatus(DateTime from, DateTime to) { var data = context diff --git a/Btms.Backend/Endpoints/AnalyticsEndpoints.cs b/Btms.Backend/Endpoints/AnalyticsEndpoints.cs index deb8967..e822da7 100644 --- a/Btms.Backend/Endpoints/AnalyticsEndpoints.cs +++ b/Btms.Backend/Endpoints/AnalyticsEndpoints.cs @@ -49,9 +49,6 @@ private static async Task GetDashboard( var movementsLinkingByCreated = await movementsService .ByCreated(DateTime.Today.MonthAgo(), DateTime.Today); - var movementsLinkingByArrival = await movementsService - .ByArrival(DateTime.Today.MonthAgo(), DateTime.Today.MonthLater()); - var lastMonthMovementsByStatus = await movementsService .ByStatus(DateTime.Today.MonthAgo(), DateTime.Now); @@ -76,8 +73,6 @@ private static async Task GetDashboard( last24HoursMovementsLinkingByCreated, last24HoursImportNotificationsLinkingByCreated, movementsLinkingByCreated, - movementsLinkingByArrival, - lastMonthImportNotificationsByTypeAndStatus, lastMonthMovementsByStatus, lastMonthMovementsByItemCount, lastMonthImportNotificationsByCommodityCount,