diff --git a/src/Api/Dirt/Controllers/OrganizationReportsController.cs b/src/Api/Dirt/Controllers/OrganizationReportsController.cs index fc76efc07107..0d60587d2cc5 100644 --- a/src/Api/Dirt/Controllers/OrganizationReportsController.cs +++ b/src/Api/Dirt/Controllers/OrganizationReportsController.cs @@ -132,15 +132,13 @@ public async Task UpdateOrganizationReportAsync(Guid organization # region SummaryData Field Endpoints /// - /// Gets summary data for organization reports within a specified date range. - /// The response is optimized for widget display by returning up to 6 entries that are - /// evenly spaced across the date range, including the most recent entry. - /// This allows the widget to show trends over time while ensuring the latest data point is always included. + /// Gets summary data for organization reports within a specified date range. + /// Returns all report summary entries within the range. /// - /// - /// - /// - /// + /// The unique identifier of the organization. + /// The start of the date range to query. + /// The end of the date range to query. + /// A collection of summary data entries within the date range. /// /// [HttpGet("{organizationId}/data/summary")] diff --git a/src/Core/Dirt/Reports/ReportFeatures/GetOrganizationReportSummaryDataByDateRangeQuery.cs b/src/Core/Dirt/Reports/ReportFeatures/GetOrganizationReportSummaryDataByDateRangeQuery.cs index 6d2d80bb3e66..5e90beed3029 100644 --- a/src/Core/Dirt/Reports/ReportFeatures/GetOrganizationReportSummaryDataByDateRangeQuery.cs +++ b/src/Core/Dirt/Reports/ReportFeatures/GetOrganizationReportSummaryDataByDateRangeQuery.cs @@ -11,7 +11,6 @@ namespace Bit.Core.Dirt.Reports.ReportFeatures; public class GetOrganizationReportSummaryDataByDateRangeQuery : IGetOrganizationReportSummaryDataByDateRangeQuery { - private const int MaxRecordsForWidget = 6; private readonly IOrganizationReportRepository _organizationReportRepo; private readonly ILogger _logger; private readonly IFusionCache _cache; @@ -53,7 +52,7 @@ public async Task> GetOrganiz factory: async _ => { var data = await _organizationReportRepo.GetSummaryDataByDateRangeAsync(organizationId, startDate, endDate); - return GetMostRecentEntries(data); + return data; }, options: new FusionCacheEntryOptions(duration: OrganizationReportCacheConstants.DurationForSummaryData), tags: [cacheTag] @@ -98,27 +97,4 @@ private static (bool IsValid, string errorMessage) ValidateRequest(Guid organiza return (true, string.Empty); } - - private static IEnumerable GetMostRecentEntries(IEnumerable data, int maxEntries = MaxRecordsForWidget) - { - if (data.Count() <= maxEntries) - { - return data; - } - - // here we need to take 10 records, evenly spaced by RevisionDate, - // to cover the entire date range, - // and ensure we include the most recent record as well - var sortedData = data.OrderByDescending(d => d.RevisionDate).ToList(); - var totalRecords = sortedData.Count; - var interval = (double)(totalRecords - 1) / (maxEntries - 1); // -1 the most recent record will be included by default - var result = new List(); - - for (int i = 0; i <= maxEntries - 1; i++) - { - result.Add(sortedData[(int)Math.Round(i * interval)]); - } - - return result; - } } diff --git a/test/Core.Test/Dirt/ReportFeatures/GetOrganizationReportSummaryDataByDateRangeQueryTests.cs b/test/Core.Test/Dirt/ReportFeatures/GetOrganizationReportSummaryDataByDateRangeQueryTests.cs index 9cf965fdd97d..34bfec459e0d 100644 --- a/test/Core.Test/Dirt/ReportFeatures/GetOrganizationReportSummaryDataByDateRangeQueryTests.cs +++ b/test/Core.Test/Dirt/ReportFeatures/GetOrganizationReportSummaryDataByDateRangeQueryTests.cs @@ -62,7 +62,7 @@ await sutProvider.GetDependency() [Theory] [BitAutoData] - public async Task GetOrganizationReportSummaryDataByDateRangeAsync_ShouldReturnTopSixResults( + public async Task GetOrganizationReportSummaryDataByDateRangeAsync_ShouldReturnAllResults( SutProvider sutProvider) { // Arrange @@ -110,7 +110,7 @@ public async Task GetOrganizationReportSummaryDataByDateRangeAsync_ShouldReturnT // Assert Assert.NotNull(result); - Assert.Equal(6, result.Count()); + Assert.Equal(12, result.Count()); await sutProvider.GetDependency() .Received(1).GetSummaryDataByDateRangeAsync(Arg.Any(), Arg.Any(), Arg.Any()); }