mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 18:53:12 +00:00
fix(dashboard): count All time over the same window the board lists (SH-392)
The Unassigned drill-down opens the board with no range, which searches 2000-01-01..2099-12-31 plus undated work. The All time count had no bounds, so a work order dated outside that window was counted but not listed. The count now uses the same window.
This commit is contained in:
parent
4876fa2717
commit
7297e30212
3 changed files with 20 additions and 2 deletions
|
|
@ -152,6 +152,9 @@ public class DashboardUnassignedTests
|
|||
{
|
||||
using var ctx = NewContext();
|
||||
Seed(ctx);
|
||||
// Dated outside the board's all-weeks window: neither side may count them.
|
||||
ctx.workOrders.AddRange(Wo(11, new DateTime(1999, 12, 31)), Wo(12, new DateTime(2100, 1, 1)));
|
||||
ctx.SaveChanges();
|
||||
var user = AccountUser(1);
|
||||
|
||||
var stats = await NewDashboard(ctx).GetStatsAsync(
|
||||
|
|
|
|||
|
|
@ -5,6 +5,14 @@ namespace SeaHaven.DataServices.Helpers
|
|||
{
|
||||
public static class WorkOrderBoardQueryFilters
|
||||
{
|
||||
/// <summary>
|
||||
/// The window the Work Orders board searches when no date range is selected
|
||||
/// (client ADVANCED_SEARCH_ALL_WEEKS_FROM/TO), used with includeDateless.
|
||||
/// Counts that drill into that list use it too, so both see the same rows.
|
||||
/// </summary>
|
||||
public static readonly DateOnly AllWeeksFrom = new(2000, 1, 1);
|
||||
public static readonly DateOnly AllWeeksTo = new(2099, 12, 31);
|
||||
|
||||
public static IQueryable<WorkOrder> ApplyBaseScope(IQueryable<WorkOrder> query)
|
||||
=> query.Where(w => w.istemplate != true && (w.IsDeleted != true || w.IsDeleted == null));
|
||||
|
||||
|
|
|
|||
|
|
@ -61,8 +61,15 @@ namespace SeaHaven.DataServices.Implementation
|
|||
query = WorkOrderBoardQueryFilters.ApplyDispatcherFilter(
|
||||
query, new[] { "__unassigned__" }, myWorkOrders: false, currentUserId: null);
|
||||
query = WorkOrderBoardQueryFilters.ApplyStatusFilter(query, OpenLifecycleStatuses);
|
||||
if (dateFrom is DateOnly from && dateTo is DateOnly to)
|
||||
query = WorkOrderBoardQueryFilters.ApplyDateRangeFilter(query, from, to);
|
||||
// All time counts what the board lists with no range: every week plus
|
||||
// undated work, so the tile and its drill-down agree (SH-392).
|
||||
query = dateFrom is DateOnly from && dateTo is DateOnly to
|
||||
? WorkOrderBoardQueryFilters.ApplyDateRangeFilter(query, from, to)
|
||||
: WorkOrderBoardQueryFilters.ApplyDateRangeFilter(
|
||||
query,
|
||||
WorkOrderBoardQueryFilters.AllWeeksFrom,
|
||||
WorkOrderBoardQueryFilters.AllWeeksTo,
|
||||
includeDateless: true);
|
||||
|
||||
return await query.CountAsync(cancellationToken);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue