mirror of
https://gitlab.com/mobicoop/v3/service/matcher.git
synced 2026-01-01 16:02:40 +00:00
create ad usecase tests
This commit is contained in:
@@ -56,57 +56,8 @@ export class CreateAdUseCase {
|
||||
withPoints: true,
|
||||
withTime: false,
|
||||
});
|
||||
this.ad.driverDistance = this.geography.driverRoute?.distance;
|
||||
this.ad.driverDuration = this.geography.driverRoute?.duration;
|
||||
this.ad.passengerDistance = this.geography.passengerRoute?.distance;
|
||||
this.ad.passengerDuration = this.geography.passengerRoute?.duration;
|
||||
this.ad.fwdAzimuth = this.geography.driverRoute
|
||||
? this.geography.driverRoute.fwdAzimuth
|
||||
: this.geography.passengerRoute.fwdAzimuth;
|
||||
this.ad.backAzimuth = this.geography.driverRoute
|
||||
? this.geography.driverRoute.backAzimuth
|
||||
: this.geography.passengerRoute.backAzimuth;
|
||||
this.ad.waypoints = this.directionEncoder.encode(
|
||||
command.createAdRequest.waypoints,
|
||||
);
|
||||
this.ad.direction = this.geography.driverRoute
|
||||
? this.directionEncoder.encode(this.geography.driverRoute.points)
|
||||
: undefined;
|
||||
this.ad.monTime = TimeConverter.toUtcDatetime(
|
||||
this.ad.fromDate,
|
||||
command.createAdRequest.monTime,
|
||||
this.timezone,
|
||||
);
|
||||
this.ad.tueTime = TimeConverter.toUtcDatetime(
|
||||
this.ad.fromDate,
|
||||
command.createAdRequest.tueTime,
|
||||
this.timezone,
|
||||
);
|
||||
this.ad.wedTime = TimeConverter.toUtcDatetime(
|
||||
this.ad.fromDate,
|
||||
command.createAdRequest.wedTime,
|
||||
this.timezone,
|
||||
);
|
||||
this.ad.thuTime = TimeConverter.toUtcDatetime(
|
||||
this.ad.fromDate,
|
||||
command.createAdRequest.thuTime,
|
||||
this.timezone,
|
||||
);
|
||||
this.ad.friTime = TimeConverter.toUtcDatetime(
|
||||
this.ad.fromDate,
|
||||
command.createAdRequest.friTime,
|
||||
this.timezone,
|
||||
);
|
||||
this.ad.satTime = TimeConverter.toUtcDatetime(
|
||||
this.ad.fromDate,
|
||||
command.createAdRequest.satTime,
|
||||
this.timezone,
|
||||
);
|
||||
this.ad.sunTime = TimeConverter.toUtcDatetime(
|
||||
this.ad.fromDate,
|
||||
command.createAdRequest.sunTime,
|
||||
this.timezone,
|
||||
);
|
||||
this.setAdGeography(command);
|
||||
this.setAdSchedule(command);
|
||||
return await this.adRepository.createAd(this.ad);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
@@ -133,4 +84,61 @@ export class CreateAdUseCase {
|
||||
private setGeography = (coordinates: Coordinate[]): void => {
|
||||
this.geography = new Geography(coordinates);
|
||||
};
|
||||
|
||||
private setAdGeography = (command: CreateAdCommand): void => {
|
||||
this.ad.driverDistance = this.geography.driverRoute?.distance;
|
||||
this.ad.driverDuration = this.geography.driverRoute?.duration;
|
||||
this.ad.passengerDistance = this.geography.passengerRoute?.distance;
|
||||
this.ad.passengerDuration = this.geography.passengerRoute?.duration;
|
||||
this.ad.fwdAzimuth = this.geography.driverRoute
|
||||
? this.geography.driverRoute.fwdAzimuth
|
||||
: this.geography.passengerRoute.fwdAzimuth;
|
||||
this.ad.backAzimuth = this.geography.driverRoute
|
||||
? this.geography.driverRoute.backAzimuth
|
||||
: this.geography.passengerRoute.backAzimuth;
|
||||
this.ad.waypoints = this.directionEncoder.encode(
|
||||
command.createAdRequest.waypoints,
|
||||
);
|
||||
this.ad.direction = this.geography.driverRoute
|
||||
? this.directionEncoder.encode(this.geography.driverRoute.points)
|
||||
: undefined;
|
||||
};
|
||||
|
||||
private setAdSchedule = (command: CreateAdCommand): void => {
|
||||
this.ad.monTime = TimeConverter.toUtcDatetime(
|
||||
this.ad.fromDate,
|
||||
command.createAdRequest.monTime,
|
||||
this.timezone,
|
||||
);
|
||||
this.ad.tueTime = TimeConverter.toUtcDatetime(
|
||||
this.ad.fromDate,
|
||||
command.createAdRequest.tueTime,
|
||||
this.timezone,
|
||||
);
|
||||
this.ad.wedTime = TimeConverter.toUtcDatetime(
|
||||
this.ad.fromDate,
|
||||
command.createAdRequest.wedTime,
|
||||
this.timezone,
|
||||
);
|
||||
this.ad.thuTime = TimeConverter.toUtcDatetime(
|
||||
this.ad.fromDate,
|
||||
command.createAdRequest.thuTime,
|
||||
this.timezone,
|
||||
);
|
||||
this.ad.friTime = TimeConverter.toUtcDatetime(
|
||||
this.ad.fromDate,
|
||||
command.createAdRequest.friTime,
|
||||
this.timezone,
|
||||
);
|
||||
this.ad.satTime = TimeConverter.toUtcDatetime(
|
||||
this.ad.fromDate,
|
||||
command.createAdRequest.satTime,
|
||||
this.timezone,
|
||||
);
|
||||
this.ad.sunTime = TimeConverter.toUtcDatetime(
|
||||
this.ad.fromDate,
|
||||
command.createAdRequest.sunTime,
|
||||
this.timezone,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user