mirror of
https://gitlab.com/mobicoop/v3/service/matcher.git
synced 2026-01-09 22:42:39 +00:00
improve candidate entity for empty driver or passenger schedule
This commit is contained in:
@@ -60,7 +60,7 @@ export class CandidateEntity extends AggregateRoot<CandidateProps> {
|
||||
* This is a tedious process : additional information can be found in deeper methods !
|
||||
*/
|
||||
createJourneys = (): CandidateEntity => {
|
||||
// driver and passenger schedules are mandatory
|
||||
// driver and passenger schedules are eventually mandatory
|
||||
if (!this.props.driverSchedule) this._createDriverSchedule();
|
||||
if (!this.props.passengerSchedule) this._createPassengerSchedule();
|
||||
try {
|
||||
@@ -96,9 +96,7 @@ export class CandidateEntity extends AggregateRoot<CandidateProps> {
|
||||
* Create the driver schedule based on the passenger schedule
|
||||
*/
|
||||
private _createDriverSchedule = (): void => {
|
||||
if (this.props.passengerSchedule) {
|
||||
let driverSchedule: ScheduleItemProps[] =
|
||||
this.props.passengerSchedule.map(
|
||||
let driverSchedule: ScheduleItemProps[] = this.props.passengerSchedule!.map(
|
||||
(scheduleItemProps: ScheduleItemProps) => ({
|
||||
day: scheduleItemProps.day,
|
||||
time: scheduleItemProps.time,
|
||||
@@ -139,7 +137,6 @@ export class CandidateEntity extends AggregateRoot<CandidateProps> {
|
||||
margin: scheduleItemProps.margin,
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -162,9 +159,7 @@ export class CandidateEntity extends AggregateRoot<CandidateProps> {
|
||||
* Create the passenger schedule based on the driver schedule
|
||||
*/
|
||||
private _createPassengerSchedule = (): void => {
|
||||
if (this.props.driverSchedule) {
|
||||
let passengerSchedule: ScheduleItemProps[] =
|
||||
this.props.driverSchedule.map(
|
||||
let passengerSchedule: ScheduleItemProps[] = this.props.driverSchedule!.map(
|
||||
(scheduleItemProps: ScheduleItemProps) => ({
|
||||
day: scheduleItemProps.day,
|
||||
time: scheduleItemProps.time,
|
||||
@@ -205,7 +200,6 @@ export class CandidateEntity extends AggregateRoot<CandidateProps> {
|
||||
margin: scheduleItemProps.margin,
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
private _createJourney = (driverScheduleItem: ScheduleItem): Journey =>
|
||||
|
||||
Reference in New Issue
Block a user