add schedule in candidate
This commit is contained in:
parent
7cac8cbef9
commit
996759d001
|
@ -1,10 +1,10 @@
|
||||||
import { Frequency, Role } from '@modules/ad/core/domain/ad.types';
|
import { Frequency, Role } from '@modules/ad/core/domain/ad.types';
|
||||||
import { Selector } from '../algorithm.abstract';
|
import { Selector } from '../algorithm.abstract';
|
||||||
import { ScheduleItem } from '../match.query';
|
|
||||||
import { Waypoint } from '../../../types/waypoint.type';
|
import { Waypoint } from '../../../types/waypoint.type';
|
||||||
import { Point } from '../../../types/point.type';
|
import { Point } from '../../../types/point.type';
|
||||||
import { CandidateEntity } from '@modules/ad/core/domain/candidate.entity';
|
import { CandidateEntity } from '@modules/ad/core/domain/candidate.entity';
|
||||||
import { AdEntity } from '@modules/ad/core/domain/ad.entity';
|
import { AdEntity } from '@modules/ad/core/domain/ad.entity';
|
||||||
|
import { ScheduleItem } from '@modules/ad/core/domain/value-objects/schedule-item.value-object';
|
||||||
|
|
||||||
export class PassengerOrientedSelector extends Selector {
|
export class PassengerOrientedSelector extends Selector {
|
||||||
select = async (): Promise<CandidateEntity[]> => {
|
select = async (): Promise<CandidateEntity[]> => {
|
||||||
|
@ -60,6 +60,22 @@ export class PassengerOrientedSelector extends Selector {
|
||||||
adsRole.role == Role.PASSENGER
|
adsRole.role == Role.PASSENGER
|
||||||
? (adEntity.getProps().driverDuration as number)
|
? (adEntity.getProps().driverDuration as number)
|
||||||
: (this.query.driverRoute?.duration as number),
|
: (this.query.driverRoute?.duration as number),
|
||||||
|
driverSchedule:
|
||||||
|
adsRole.role == Role.PASSENGER
|
||||||
|
? adEntity.getProps().schedule
|
||||||
|
: this.query.schedule.map((scheduleItem: ScheduleItem) => ({
|
||||||
|
day: scheduleItem.day as number,
|
||||||
|
time: scheduleItem.time,
|
||||||
|
margin: scheduleItem.margin as number,
|
||||||
|
})),
|
||||||
|
passengerSchedule:
|
||||||
|
adsRole.role == Role.DRIVER
|
||||||
|
? adEntity.getProps().schedule
|
||||||
|
: this.query.schedule.map((scheduleItem: ScheduleItem) => ({
|
||||||
|
day: scheduleItem.day as number,
|
||||||
|
time: scheduleItem.time,
|
||||||
|
margin: scheduleItem.margin as number,
|
||||||
|
})),
|
||||||
spacetimeDetourRatio: {
|
spacetimeDetourRatio: {
|
||||||
maxDistanceDetourRatio: this.query
|
maxDistanceDetourRatio: this.query
|
||||||
.maxDetourDistanceRatio as number,
|
.maxDetourDistanceRatio as number,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { Role } from './ad.types';
|
import { Role } from './ad.types';
|
||||||
import { PointProps } from './value-objects/point.value-object';
|
import { PointProps } from './value-objects/point.value-object';
|
||||||
|
import { ScheduleItemProps } from './value-objects/schedule-item.value-object';
|
||||||
import { WayStepProps } from './value-objects/waystep.value-object';
|
import { WayStepProps } from './value-objects/waystep.value-object';
|
||||||
|
|
||||||
// All properties that a Candidate has
|
// All properties that a Candidate has
|
||||||
|
@ -12,6 +13,8 @@ export interface CandidateProps {
|
||||||
carpoolSteps?: WayStepProps[]; // carpool path for the crew (driver + passenger)
|
carpoolSteps?: WayStepProps[]; // carpool path for the crew (driver + passenger)
|
||||||
distance?: number;
|
distance?: number;
|
||||||
duration?: number;
|
duration?: number;
|
||||||
|
driverSchedule: ScheduleItemProps[];
|
||||||
|
passengerSchedule: ScheduleItemProps[];
|
||||||
spacetimeDetourRatio: SpacetimeDetourRatio;
|
spacetimeDetourRatio: SpacetimeDetourRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +26,8 @@ export interface CreateCandidateProps {
|
||||||
driverDuration: number;
|
driverDuration: number;
|
||||||
driverWaypoints: PointProps[];
|
driverWaypoints: PointProps[];
|
||||||
passengerWaypoints: PointProps[];
|
passengerWaypoints: PointProps[];
|
||||||
|
driverSchedule: ScheduleItemProps[];
|
||||||
|
passengerSchedule: ScheduleItemProps[];
|
||||||
spacetimeDetourRatio: SpacetimeDetourRatio;
|
spacetimeDetourRatio: SpacetimeDetourRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,20 @@ class SomeSelector extends Selector {
|
||||||
],
|
],
|
||||||
driverDistance: 350145,
|
driverDistance: 350145,
|
||||||
driverDuration: 13548,
|
driverDuration: 13548,
|
||||||
|
driverSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:00',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
passengerSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:10',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
spacetimeDetourRatio: {
|
spacetimeDetourRatio: {
|
||||||
maxDistanceDetourRatio: 0.3,
|
maxDistanceDetourRatio: 0.3,
|
||||||
maxDurationDetourRatio: 0.3,
|
maxDurationDetourRatio: 0.3,
|
||||||
|
|
|
@ -31,6 +31,20 @@ describe('Candidate entity', () => {
|
||||||
],
|
],
|
||||||
driverDistance: 350145,
|
driverDistance: 350145,
|
||||||
driverDuration: 13548,
|
driverDuration: 13548,
|
||||||
|
driverSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:00',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
passengerSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:10',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
spacetimeDetourRatio: {
|
spacetimeDetourRatio: {
|
||||||
maxDistanceDetourRatio: 0.3,
|
maxDistanceDetourRatio: 0.3,
|
||||||
maxDurationDetourRatio: 0.3,
|
maxDurationDetourRatio: 0.3,
|
||||||
|
@ -64,6 +78,20 @@ describe('Candidate entity', () => {
|
||||||
],
|
],
|
||||||
driverDistance: 350145,
|
driverDistance: 350145,
|
||||||
driverDuration: 13548,
|
driverDuration: 13548,
|
||||||
|
driverSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:00',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
passengerSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:10',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
spacetimeDetourRatio: {
|
spacetimeDetourRatio: {
|
||||||
maxDistanceDetourRatio: 0.3,
|
maxDistanceDetourRatio: 0.3,
|
||||||
maxDurationDetourRatio: 0.3,
|
maxDurationDetourRatio: 0.3,
|
||||||
|
@ -130,6 +158,20 @@ describe('Candidate entity', () => {
|
||||||
],
|
],
|
||||||
driverDistance: 350145,
|
driverDistance: 350145,
|
||||||
driverDuration: 13548,
|
driverDuration: 13548,
|
||||||
|
driverSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:00',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
passengerSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:10',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
spacetimeDetourRatio: {
|
spacetimeDetourRatio: {
|
||||||
maxDistanceDetourRatio: 0.3,
|
maxDistanceDetourRatio: 0.3,
|
||||||
maxDurationDetourRatio: 0.3,
|
maxDurationDetourRatio: 0.3,
|
||||||
|
@ -164,6 +206,20 @@ describe('Candidate entity', () => {
|
||||||
],
|
],
|
||||||
driverDistance: 350145,
|
driverDistance: 350145,
|
||||||
driverDuration: 13548,
|
driverDuration: 13548,
|
||||||
|
driverSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:00',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
passengerSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:10',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
spacetimeDetourRatio: {
|
spacetimeDetourRatio: {
|
||||||
maxDistanceDetourRatio: 0.3,
|
maxDistanceDetourRatio: 0.3,
|
||||||
maxDurationDetourRatio: 0.3,
|
maxDurationDetourRatio: 0.3,
|
||||||
|
@ -197,6 +253,20 @@ describe('Candidate entity', () => {
|
||||||
],
|
],
|
||||||
driverDistance: 350145,
|
driverDistance: 350145,
|
||||||
driverDuration: 13548,
|
driverDuration: 13548,
|
||||||
|
driverSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:00',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
passengerSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:10',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
spacetimeDetourRatio: {
|
spacetimeDetourRatio: {
|
||||||
maxDistanceDetourRatio: 0.3,
|
maxDistanceDetourRatio: 0.3,
|
||||||
maxDurationDetourRatio: 0.3,
|
maxDurationDetourRatio: 0.3,
|
||||||
|
|
|
@ -72,6 +72,20 @@ const candidates: CandidateEntity[] = [
|
||||||
],
|
],
|
||||||
driverDistance: 350145,
|
driverDistance: 350145,
|
||||||
driverDuration: 13548,
|
driverDuration: 13548,
|
||||||
|
driverSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:00',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
passengerSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:10',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
spacetimeDetourRatio: {
|
spacetimeDetourRatio: {
|
||||||
maxDistanceDetourRatio: 0.3,
|
maxDistanceDetourRatio: 0.3,
|
||||||
maxDurationDetourRatio: 0.3,
|
maxDurationDetourRatio: 0.3,
|
||||||
|
@ -102,6 +116,20 @@ const candidates: CandidateEntity[] = [
|
||||||
],
|
],
|
||||||
driverDistance: 350145,
|
driverDistance: 350145,
|
||||||
driverDuration: 13548,
|
driverDuration: 13548,
|
||||||
|
driverSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:00',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
passengerSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:10',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
spacetimeDetourRatio: {
|
spacetimeDetourRatio: {
|
||||||
maxDistanceDetourRatio: 0.3,
|
maxDistanceDetourRatio: 0.3,
|
||||||
maxDurationDetourRatio: 0.3,
|
maxDurationDetourRatio: 0.3,
|
||||||
|
|
|
@ -71,6 +71,20 @@ const candidate: CandidateEntity = CandidateEntity.create({
|
||||||
],
|
],
|
||||||
driverDistance: 350145,
|
driverDistance: 350145,
|
||||||
driverDuration: 13548,
|
driverDuration: 13548,
|
||||||
|
driverSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:00',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
passengerSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:10',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
spacetimeDetourRatio: {
|
spacetimeDetourRatio: {
|
||||||
maxDistanceDetourRatio: 0.3,
|
maxDistanceDetourRatio: 0.3,
|
||||||
maxDurationDetourRatio: 0.3,
|
maxDurationDetourRatio: 0.3,
|
||||||
|
|
|
@ -91,6 +91,20 @@ const candidate: CandidateEntity = CandidateEntity.create({
|
||||||
],
|
],
|
||||||
driverDistance: 350145,
|
driverDistance: 350145,
|
||||||
driverDuration: 13548,
|
driverDuration: 13548,
|
||||||
|
driverSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:00',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
passengerSchedule: [
|
||||||
|
{
|
||||||
|
day: 0,
|
||||||
|
time: '07:10',
|
||||||
|
margin: 900,
|
||||||
|
},
|
||||||
|
],
|
||||||
spacetimeDetourRatio: {
|
spacetimeDetourRatio: {
|
||||||
maxDistanceDetourRatio: 0.3,
|
maxDistanceDetourRatio: 0.3,
|
||||||
maxDurationDetourRatio: 0.3,
|
maxDurationDetourRatio: 0.3,
|
||||||
|
|
Loading…
Reference in New Issue