Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cdms 179 additional metrics #6

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 0 additions & 49 deletions Btms.Analytics.Tests/MovementsByArrivalDateTests.cs

This file was deleted.

1 change: 0 additions & 1 deletion Btms.Analytics/IMovementsAggregationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ namespace Btms.Analytics;
public interface IMovementsAggregationService
{
public Task<MultiSeriesDatetimeDataset[]> ByCreated(DateTime from, DateTime to, AggregationPeriod aggregateBy = AggregationPeriod.Day);
public Task<MultiSeriesDatetimeDataset[]> ByArrival(DateTime from, DateTime to, AggregationPeriod aggregateBy = AggregationPeriod.Day);
public Task<SingeSeriesDataset> ByStatus(DateTime from, DateTime to);
public Task<MultiSeriesDataset[]> ByItemCount(DateTime from, DateTime to);
public Task<MultiSeriesDataset[]> ByUniqueDocumentReferenceCount(DateTime from, DateTime to);
Expand Down
19 changes: 0 additions & 19 deletions Btms.Analytics/MovementsAggregationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,6 @@ public Task<MultiSeriesDatetimeDataset[]> ByCreated(DateTime from, DateTime to,
return Aggregate(dateRange, CreateDatasetName, matchFilter, "$createdSource", aggregateBy);
}

/// <summary>
/// Aggregates movements by arrival date and returns counts by date period. Could be refactored to use a generic/interface in time
/// </summary>
/// <param name="from">Time period to search from (inclusive)</param>
/// <param name="to">Time period to search to (exclusive)</param>
/// <param name="aggregateBy">Aggregate by day/hour</param>
/// <returns></returns>
public Task<MultiSeriesDatetimeDataset[]> ByArrival(DateTime from, DateTime to, AggregationPeriod aggregateBy = AggregationPeriod.Day)
{
var dateRange = AnalyticsHelpers.CreateDateRange(from, to, aggregateBy);

Expression<Func<Movement, bool>> 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<SingeSeriesDataset> ByStatus(DateTime from, DateTime to)
{
var data = context
Expand Down
5 changes: 0 additions & 5 deletions Btms.Backend/Endpoints/AnalyticsEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ private static async Task<IResult> 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);

Expand All @@ -76,8 +73,6 @@ private static async Task<IResult> GetDashboard(
last24HoursMovementsLinkingByCreated,
last24HoursImportNotificationsLinkingByCreated,
movementsLinkingByCreated,
movementsLinkingByArrival,
lastMonthImportNotificationsByTypeAndStatus,
lastMonthMovementsByStatus,
lastMonthMovementsByItemCount,
lastMonthImportNotificationsByCommodityCount,
Expand Down
Loading