mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 13:38:20 +00:00
changes
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import type { Freight } from '@edr/types';
|
||||
|
||||
import { YardScopeService } from '../rule-engine/services/yard-scope.service';
|
||||
import { BookingRequestRepository } from './booking-request.repository';
|
||||
import { ContractsService } from './contracts.service';
|
||||
import { ContractBookingService } from './contract-booking.service';
|
||||
@@ -28,6 +29,7 @@ export class BookingRequestService {
|
||||
private readonly contractsService: ContractsService,
|
||||
private readonly contractBookingService: ContractBookingService,
|
||||
private readonly notifier: ContractNotifierService,
|
||||
private readonly yardScope: YardScopeService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -168,8 +170,25 @@ export class BookingRequestService {
|
||||
return request;
|
||||
}
|
||||
|
||||
queue(): Promise<BookingRequest[]> {
|
||||
return this.repo.findQueue();
|
||||
/**
|
||||
* GL queue narrowed to the caller's yards: a request stays when its route's
|
||||
* ORIGIN or DESTINATION yard is one the caller's active position is mapped to
|
||||
* (unmapped position / super admin → everything). A request with no
|
||||
* resolvable route (no `contractRouteId` on a multi-route contract) has no
|
||||
* yards to judge by and is kept visible.
|
||||
*/
|
||||
async queue(user?: unknown): Promise<BookingRequest[]> {
|
||||
const rows = await this.repo.findQueue();
|
||||
const scope = await this.yardScope.getScopedYardIds(user as never);
|
||||
if (scope === null) return rows;
|
||||
return rows.filter((r) => {
|
||||
const routes = r.contract?.routes ?? [];
|
||||
const route =
|
||||
routes.find((x) => x.id === r.contractRouteId) ??
|
||||
(routes.length === 1 ? routes[0] : undefined);
|
||||
if (!route) return true;
|
||||
return scope.includes(route.originYardId) || scope.includes(route.destinationYardId);
|
||||
});
|
||||
}
|
||||
|
||||
private async findPending(requestId: string): Promise<BookingRequest> {
|
||||
|
||||
Reference in New Issue
Block a user