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 { 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 { v4 } from 'uuid';
|
||||||
|
import { AD_DIRECTION_ENCODER } from './ad.di-tokens';
|
||||||
|
import { AdEntity } from './core/domain/ad.entity';
|
||||||
import {
|
import {
|
||||||
ScheduleItem,
|
ScheduleItem,
|
||||||
ScheduleItemProps,
|
ScheduleItemProps,
|
||||||
} from './core/domain/value-objects/schedule-item.value-object';
|
} from './core/domain/value-objects/schedule-item.value-object';
|
||||||
import { DirectionEncoderPort } from '@modules/geography/core/application/ports/direction-encoder.port';
|
import {
|
||||||
import { AD_DIRECTION_ENCODER } from './ad.di-tokens';
|
AdReadModel,
|
||||||
import { ExtendedMapper } from '@mobicoop/ddd-library';
|
AdWriteExtraModel,
|
||||||
|
AdWriteModel,
|
||||||
|
ScheduleItemModel,
|
||||||
|
} from './infrastructure/ad.repository';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapper constructs objects that are used in different layers:
|
* Mapper constructs objects that are used in different layers:
|
||||||
|
@ -97,7 +97,7 @@ export class AdMapper
|
||||||
frequency: record.frequency,
|
frequency: record.frequency,
|
||||||
fromDate: record.fromDate.toISOString().split('T')[0],
|
fromDate: record.fromDate.toISOString().split('T')[0],
|
||||||
toDate: record.toDate.toISOString().split('T')[0],
|
toDate: record.toDate.toISOString().split('T')[0],
|
||||||
schedule: record.schedule.map(
|
schedule: record.schedule?.map(
|
||||||
(scheduleItem: ScheduleItemModel) =>
|
(scheduleItem: ScheduleItemModel) =>
|
||||||
new ScheduleItem({
|
new ScheduleItem({
|
||||||
day: scheduleItem.day,
|
day: scheduleItem.day,
|
||||||
|
@ -111,12 +111,14 @@ export class AdMapper
|
||||||
margin: scheduleItem.margin,
|
margin: scheduleItem.margin,
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
waypoints: this.directionEncoder
|
waypoints: record.waypoints
|
||||||
.decode(record.waypoints)
|
? this.directionEncoder
|
||||||
.map((coordinates, index) => ({
|
.decode(record.waypoints)
|
||||||
position: index,
|
.map((coordinates, index) => ({
|
||||||
...coordinates,
|
position: index,
|
||||||
})),
|
...coordinates,
|
||||||
|
}))
|
||||||
|
: [],
|
||||||
fwdAzimuth: record.fwdAzimuth,
|
fwdAzimuth: record.fwdAzimuth,
|
||||||
backAzimuth: record.backAzimuth,
|
backAzimuth: record.backAzimuth,
|
||||||
points: [],
|
points: [],
|
||||||
|
|
Loading…
Reference in New Issue