simplify ad georouter signature

This commit is contained in:
sbriat 2023-08-22 13:28:37 +02:00
parent 52a1a815e6
commit 4762c844e1
5 changed files with 7 additions and 18 deletions

View File

@ -38,11 +38,7 @@ export class AdMapper
const roles: Role[] = []; const roles: Role[] = [];
if (copy.driver) roles.push(Role.DRIVER); if (copy.driver) roles.push(Role.DRIVER);
if (copy.passenger) roles.push(Role.PASSENGER); if (copy.passenger) roles.push(Role.PASSENGER);
const route: Route = this.routeProvider.get(roles, copy.waypoints, { const route: Route = this.routeProvider.getBasic(roles, copy.waypoints);
points: true,
detailedDistance: false,
detailedDuration: false,
});
const record: AdWriteModel = { const record: AdWriteModel = {
uuid: copy.id, uuid: copy.id,
driver: copy.driver, driver: copy.driver,

View File

@ -1,12 +1,10 @@
import { GeorouterSettings } from '../types/georouter-settings.type';
import { Role } from '../../domain/ad.types'; import { Role } from '../../domain/ad.types';
import { Waypoint } from '../types/waypoint.type'; import { Waypoint } from '../types/waypoint.type';
import { Route } from '../types/route.type'; import { Route } from '../types/route.type';
export interface RouteProviderPort { export interface RouteProviderPort {
get( /**
roles: Role[], * Get a basic route with points and overall duration / distance
waypoints: Waypoint[], */
georouterSettings: GeorouterSettings, getBasic(roles: Role[], waypoints: Waypoint[]): Route;
): Route;
} }

View File

@ -1,5 +0,0 @@
export type GeorouterSettings = {
points: boolean;
detailedDuration: boolean;
detailedDistance: boolean;
};

View File

@ -105,7 +105,7 @@ const mockDirectionEncoder: DirectionEncoderPort = {
}; };
const mockRouteProvider: RouteProviderPort = { const mockRouteProvider: RouteProviderPort = {
get: jest.fn().mockImplementation(() => ({ getBasic: jest.fn().mockImplementation(() => ({
driverDistance: 350101, driverDistance: 350101,
driverDuration: 14422, driverDuration: 14422,
passengerDistance: 350101, passengerDistance: 350101,

View File

@ -20,7 +20,7 @@ const mockDirectionEncoder: DirectionEncoderPort = {
}; };
const mockRouteProvider: RouteProviderPort = { const mockRouteProvider: RouteProviderPort = {
get: jest.fn(), getBasic: jest.fn(),
}; };
describe('Ad repository', () => { describe('Ad repository', () => {