mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 13:03:12 +00:00
* feat(work-orders): enrich board search overdue filters and 0-based paging * fix(work-orders): align stacked services with CI build * fix(tests): pass userDataService in comment service unit test * fix(work-orders): use dedicated overdue query flag Stop treating WorkOrderType.Other as an overdue sentinel. Board and advanced search now accept overdue=true while types=Other filters real Other rows; combining both uses OR. * test(work-orders): cover overdue date/status boundary and Other type-filter Lock the PR #23 overdue regression boundary through the public advanced search service. Prove overdue filtering is driven by past-due date plus non-terminal status, not by the WorkOrderType.Other sentinel: - Other + future/not-completed excluded from overdue - past-due + Scheduled included; past-due + Completed/Canceled excluded - types=[PM, Other] keeps real Other rows and does not pull past-due rows - assert 0-based paging (Page=0) is preserved alongside overdue/type filters --------- Co-authored-by: Arthur Bassi <arthur.winiarski.ranger@outlook.com> Co-authored-by: Alexandre Brandizzi <alex_brandizzi@hotmail.com>
67 lines
2.3 KiB
C#
67 lines
2.3 KiB
C#
using SeaHaven.DataServices.Helpers;
|
|
using SeaHaven.DataServices.Interfaces;
|
|
using SeaHaven.Services.DTOs;
|
|
using SeaHaven.Services.Helpers;
|
|
using SeaHaven.Services.Interfaces;
|
|
|
|
namespace SeaHaven.Services.Implementation
|
|
{
|
|
public class WorkOrderAdvancedSearchService : IWorkOrderAdvancedSearchService
|
|
{
|
|
private const int DefaultPageSize = 100;
|
|
private const int MaxPageSize = 100;
|
|
|
|
private readonly IWorkOrderAdvancedSearchDataService _searchDataService;
|
|
|
|
public WorkOrderAdvancedSearchService(IWorkOrderAdvancedSearchDataService searchDataService)
|
|
{
|
|
_searchDataService = searchDataService;
|
|
}
|
|
|
|
public async Task<PagedResult<WorkOrderBoardRowDto>> SearchAsync(
|
|
WorkOrderAdvancedSearchQueryDto query,
|
|
string? currentUserId)
|
|
{
|
|
var page = query.Page < 0 ? 0 : query.Page;
|
|
var pageSize = query.PageSize < 1 ? DefaultPageSize : Math.Min(query.PageSize, MaxPageSize);
|
|
|
|
var dateRange = WorkOrderSearchDateRangeResolver.Resolve(
|
|
query.DatePreset,
|
|
query.DateFrom,
|
|
query.DateTo);
|
|
|
|
var sortBy = WorkOrderBoardSortFields.NormalizeOrThrow(query.SortBy);
|
|
|
|
var dataQuery = new WorkOrderAdvancedSearchQuery(
|
|
WorkOrderBoardSearchFilter.NormalizeSearch(query.Search),
|
|
dateRange.From,
|
|
dateRange.To,
|
|
query.Sites,
|
|
query.Types,
|
|
query.Overdue,
|
|
query.Dispatchers,
|
|
query.Statuses,
|
|
query.PmTypes,
|
|
query.VendorIds,
|
|
query.DocStatuses,
|
|
query.MyWorkOrders,
|
|
currentUserId,
|
|
page,
|
|
pageSize,
|
|
sortBy,
|
|
query.SortDir ?? "asc");
|
|
|
|
var result = await _searchDataService.SearchAsync(dataQuery);
|
|
var utcNow = DateTime.UtcNow;
|
|
|
|
return new PagedResult<WorkOrderBoardRowDto>
|
|
{
|
|
Items = result.Rows.Select(r => WorkOrderBoardService.MapRawRow(r, utcNow)).ToList(),
|
|
TotalCount = result.TotalCount,
|
|
Page = page,
|
|
PageSize = pageSize,
|
|
PageBase = 0
|
|
};
|
|
}
|
|
}
|
|
}
|