Project report for the workspace dashboard
C# · ASP.NET Core · intermediate · modification
Adds the per-project report the new dashboard table reads. `ReportsController` gets `GET /api/reports/projects`: it lists the workspace's active projects in name order and counts each project's open, done and overdue tasks, with today's UTC date taken from the injected `TimeProvider`. The response row is the new `ProjectReportRow` record in `ReportDtos.cs`, next to the existing summary record. `ProjectReportTests.cs` adds endpoint tests on the existing `PlannerApiFactory`.
ASP.NET Core 10 Web API on .NET 10 (C# 14, nullable reference types enabled, implicit usings), controllers with `[ApiController]`. EF Core 10 with Npgsql on PostgreSQL 16 in production; the database is a managed instance in the same region as the API. `PlannerDbContext` is unchanged: `Projects` is the `Project` entity (`int Id`, `int WorkspaceId`, `string Name`, `bool Archived`, and the `Tasks` collection navigation), `Tasks` is the `ProjectTask` entity (`int Id`, `int ProjectId` with its `Project` navigation, `string Title`, `TaskState State`, `DateOnly? DueOn` mapped to a `date` column). `TaskState` is an enum, `Todo`, `InProgress` or `Done`, stored as an integer. The `tasks.ProjectId` foreign key has its index (the EF Core convention). No lazy-loading proxies are configured. `Program.cs` is unchanged: it registers the DbContext, `TimeProvider.System` as a singleton, controllers and JWT bearer authentication; every token carries a `workspace_id` claim, read by `User.GetWorkspaceId()` (`Planner.Api.Auth`, existing). Tests use xUnit and the existing `PlannerApiFactory` (`WebApplicationFactory<Program>` over an in-memory SQLite database, `TimeProvider` pinned to 2026-10-15 12:00 UTC, exposed as `PlannerApiFactory.Today`): `NewWorkspaceId()` returns an unused workspace id, `CreateClientFor(workspaceId)` signs requests in as a member of that workspace, and `SeedProjectAsync(workspaceId, name, archived, tasks)` inserts a project with the given `(State, DueOn)` tasks. The dashboard table ships separately in the web app.
Requirements
- `GET /api/reports/projects` (new) returns one row per active (not archived) project of the caller's workspace, as `{ "projectId", "name", "openTasks", "doneTasks", "overdueTasks" }`, ordered by `Name` as the database sorts it, ties by `Id`. A project with no tasks gets a row with zeros; a workspace with no active projects gets `[]`.
- `openTasks` counts the project's tasks that are not `Done` (`Todo` or `InProgress`), `doneTasks` the `Done` ones. `overdueTasks` counts open tasks whose `DueOn` is before today; a task due today is not overdue yet, a task with no `DueOn` is never overdue, and a `Done` task never counts. "Today" is the current UTC calendar date from the injected `TimeProvider`.
- Scale: a workspace has up to 500 active projects and a project up to 5,000 tasks. The report backs the workspace dashboard, which every member opens when they sign in, so the endpoint must run a fixed number of SQL queries per request (at most 2), however many projects the workspace has.
- Unchanged: the controller requires a signed-in user (`[Authorize]`, 401 otherwise), every member of a workspace may see all of its projects, and `GET /api/reports/summary` keeps its behaviour.
Files touched
- src/Planner.Api/Reports/ReportsController.cs
- src/Planner.Api/Reports/ReportDtos.cs
- tests/Planner.Api.Tests/ProjectReportTests.cs