mirror of
https://gitlab.com/mobicoop/v3/service/matcher.git
synced 2026-01-01 14:02:39 +00:00
simplify ad georouter signature
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export type GeorouterSettings = {
|
||||
points: boolean;
|
||||
detailedDuration: boolean;
|
||||
detailedDistance: boolean;
|
||||
};
|
||||
@@ -105,7 +105,7 @@ const mockDirectionEncoder: DirectionEncoderPort = {
|
||||
};
|
||||
|
||||
const mockRouteProvider: RouteProviderPort = {
|
||||
get: jest.fn().mockImplementation(() => ({
|
||||
getBasic: jest.fn().mockImplementation(() => ({
|
||||
driverDistance: 350101,
|
||||
driverDuration: 14422,
|
||||
passengerDistance: 350101,
|
||||
|
||||
@@ -20,7 +20,7 @@ const mockDirectionEncoder: DirectionEncoderPort = {
|
||||
};
|
||||
|
||||
const mockRouteProvider: RouteProviderPort = {
|
||||
get: jest.fn(),
|
||||
getBasic: jest.fn(),
|
||||
};
|
||||
|
||||
describe('Ad repository', () => {
|
||||
|
||||
Reference in New Issue
Block a user