From cd1f8a04a16bbd0d56cc1b9b363d7bb369ce6a82 Mon Sep 17 00:00:00 2001 From: cesnimda Date: Sat, 4 Jul 2026 21:21:12 +0200 Subject: [PATCH] chore(analytics): remove dead day-hour heatmap endpoint/service/DTO Unused after the frontend widget removal (#44); category-heatmap kept. Build+tests green. Co-Authored-By: Claude Opus 4.8 --- .../Controllers/AnalyticsController.cs | 3 --- .../Abstractions/IServices.cs | 1 - src/InboxIntel.Application/DTOs/AnalyticsDtos.cs | 2 -- .../Analytics/AnalyticsService.cs | 16 +--------------- 4 files changed, 1 insertion(+), 21 deletions(-) diff --git a/src/InboxIntel.Api/Controllers/AnalyticsController.cs b/src/InboxIntel.Api/Controllers/AnalyticsController.cs index 43563a4..f1fd3f3 100644 --- a/src/InboxIntel.Api/Controllers/AnalyticsController.cs +++ b/src/InboxIntel.Api/Controllers/AnalyticsController.cs @@ -24,9 +24,6 @@ public class AnalyticsController : ApiControllerBase public async Task Volume([FromQuery] int days = 90, CancellationToken ct = default) => Ok(await _analytics.GetVolumeOverTimeAsync(UserId, Math.Clamp(days, 1, 3660), ct)); - [HttpGet("heatmap")] - public async Task Heatmap(CancellationToken ct) => Ok(await _analytics.GetHeatmapAsync(UserId, ct)); - [HttpGet("category-heatmap")] public async Task CategoryHeatmap(CancellationToken ct) => Ok(await _analytics.GetCategoryHeatmapAsync(UserId, ct)); diff --git a/src/InboxIntel.Application/Abstractions/IServices.cs b/src/InboxIntel.Application/Abstractions/IServices.cs index 3a84c90..b70e308 100644 --- a/src/InboxIntel.Application/Abstractions/IServices.cs +++ b/src/InboxIntel.Application/Abstractions/IServices.cs @@ -22,7 +22,6 @@ public interface IAnalyticsService Task GetInboxHealthAsync(Guid userId, CancellationToken ct = default); Task> GetTopSendersAsync(Guid userId, int take = 20, CancellationToken ct = default); Task> GetVolumeOverTimeAsync(Guid userId, int days = 90, CancellationToken ct = default); - Task> GetHeatmapAsync(Guid userId, CancellationToken ct = default); Task> GetCategoryHeatmapAsync(Guid userId, CancellationToken ct = default); Task> GetAttachmentBreakdownAsync(Guid userId, CancellationToken ct = default); Task GetSidebarCountsAsync(Guid userId, CancellationToken ct = default); diff --git a/src/InboxIntel.Application/DTOs/AnalyticsDtos.cs b/src/InboxIntel.Application/DTOs/AnalyticsDtos.cs index da08f1c..9ce7942 100644 --- a/src/InboxIntel.Application/DTOs/AnalyticsDtos.cs +++ b/src/InboxIntel.Application/DTOs/AnalyticsDtos.cs @@ -12,7 +12,6 @@ public record InboxHealthDto( public record TimeSeriesPointDto(DateOnly Day, int Count); -public record HeatmapCellDto(int DayOfWeek, int Hour, int Count); /// Email counts per category per day-of-week, for the category heatmap. public record CategoryHeatmapCellDto(string Category, int DayOfWeek, int Count); @@ -39,6 +38,5 @@ public record DashboardSummaryDto( int UnreadEmails, IReadOnlyList TopSenders, IReadOnlyList VolumeOverTime, - IReadOnlyList Heatmap, IReadOnlyList AttachmentBreakdown, long StorageEstimateBytes); diff --git a/src/InboxIntel.Infrastructure/Analytics/AnalyticsService.cs b/src/InboxIntel.Infrastructure/Analytics/AnalyticsService.cs index 7cb9fe2..4b9be89 100644 --- a/src/InboxIntel.Infrastructure/Analytics/AnalyticsService.cs +++ b/src/InboxIntel.Infrastructure/Analytics/AnalyticsService.cs @@ -16,11 +16,10 @@ public class AnalyticsService : IAnalyticsService var health = await GetInboxHealthAsync(userId, ct); var top = await GetTopSendersAsync(userId, 10, ct); var volume = await GetVolumeOverTimeAsync(userId, 90, ct); - var heatmap = await GetHeatmapAsync(userId, ct); var attachments = await GetAttachmentBreakdownAsync(userId, ct); return new DashboardSummaryDto( - health, health.TotalEmails, health.UnreadEmails, top, volume, heatmap, attachments, + health, health.TotalEmails, health.UnreadEmails, top, volume, attachments, health.EstimatedStorageBytes); } @@ -75,19 +74,6 @@ public class AnalyticsService : IAnalyticsService .ToList(); } - public async Task> GetHeatmapAsync(Guid userId, CancellationToken ct = default) - { - var raw = await _db.Emails - .Where(e => e.UserId == userId) - .Select(e => new { e.SentAtUtc }) - .ToListAsync(ct); - - return raw - .GroupBy(x => new { Dow = (int)x.SentAtUtc.DayOfWeek, Hour = x.SentAtUtc.Hour }) - .Select(g => new HeatmapCellDto(g.Key.Dow, g.Key.Hour, g.Count())) - .ToList(); - } - public async Task> GetCategoryHeatmapAsync(Guid userId, CancellationToken ct = default) { var raw = await _db.Emails -- 2.52.0