fix retrieval of DB records not including schedule or waypoints
This commit is contained in:
parent
01ebac7e74
commit
a7c281d740
|
@ -1,19 +1,19 @@
|
|||
import { ExtendedMapper } from '@mobicoop/ddd-library';
|
||||
import { DirectionEncoderPort } from '@modules/geography/core/application/ports/direction-encoder.port';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { AdEntity } from './core/domain/ad.entity';
|
||||
import {
|
||||
AdWriteModel,
|
||||
AdReadModel,
|
||||
ScheduleItemModel,
|
||||
AdWriteExtraModel,
|
||||
} from './infrastructure/ad.repository';
|
||||
import { v4 } from 'uuid';
|
||||
import { AD_DIRECTION_ENCODER } from './ad.di-tokens';
|
||||
import { AdEntity } from './core/domain/ad.entity';
|
||||
import {
|
||||
ScheduleItem,
|
||||
ScheduleItemProps,
|
||||
} from './core/domain/value-objects/schedule-item.value-object';
|
||||
import { DirectionEncoderPort } from '@modules/geography/core/application/ports/direction-encoder.port';
|
||||
import { AD_DIRECTION_ENCODER } from './ad.di-tokens';
|
||||
import { ExtendedMapper } from '@mobicoop/ddd-library';
|
||||
import {
|
||||
AdReadModel,
|
||||
AdWriteExtraModel,
|
||||
AdWriteModel,
|
||||
ScheduleItemModel,
|
||||
} from './infrastructure/ad.repository';
|
||||
|
||||
/**
|
||||
* Mapper constructs objects that are used in different layers:
|
||||
|
@ -97,7 +97,7 @@ export class AdMapper
|
|||
frequency: record.frequency,
|
||||
fromDate: record.fromDate.toISOString().split('T')[0],
|
||||
toDate: record.toDate.toISOString().split('T')[0],
|
||||
schedule: record.schedule.map(
|
||||
schedule: record.schedule?.map(
|
||||
(scheduleItem: ScheduleItemModel) =>
|
||||
new ScheduleItem({
|
||||
day: scheduleItem.day,
|
||||
|
@ -111,12 +111,14 @@ export class AdMapper
|
|||
margin: scheduleItem.margin,
|
||||
}),
|
||||
),
|
||||
waypoints: this.directionEncoder
|
||||
waypoints: record.waypoints
|
||||
? this.directionEncoder
|
||||
.decode(record.waypoints)
|
||||
.map((coordinates, index) => ({
|
||||
position: index,
|
||||
...coordinates,
|
||||
})),
|
||||
}))
|
||||
: [],
|
||||
fwdAzimuth: record.fwdAzimuth,
|
||||
backAzimuth: record.backAzimuth,
|
||||
points: [],
|
||||
|
|
Loading…
Reference in New Issue