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[] = [];
if (copy.driver) roles.push(Role.DRIVER);
if (copy.passenger) roles.push(Role.PASSENGER);
const route: Route = this.routeProvider.get(roles, copy.waypoints, {
points: true,
detailedDistance: false,
detailedDuration: false,
});
const route: Route = this.routeProvider.getBasic(roles, copy.waypoints);
const record: AdWriteModel = {
uuid: copy.id,
driver: copy.driver,

View File

@ -1,12 +1,10 @@
import { GeorouterSettings } from '../types/georouter-settings.type';
import { Role } from '../../domain/ad.types';
import { Waypoint } from '../types/waypoint.type';
import { Route } from '../types/route.type';
export interface RouteProviderPort {
get(
roles: Role[],
waypoints: Waypoint[],
georouterSettings: GeorouterSettings,
): Route;
/**
* Get a basic route with points and overall duration / distance
*/
getBasic(roles: Role[], waypoints: Waypoint[]): 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 = {
get: jest.fn().mockImplementation(() => ({
getBasic: jest.fn().mockImplementation(() => ({
driverDistance: 350101,
driverDuration: 14422,
passengerDistance: 350101,

View File

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