Merge branch 'pause-ad' into 'next-release'
Draft: feat(pause ad): add first basic ad pause flag See merge request mobicoop/v3/service/matcher!48
This commit is contained in:
commit
96108ac873
|
@ -0,0 +1,2 @@
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "ad" ADD COLUMN "pause" BOOLEAN NOT NULL DEFAULT false;
|
|
@ -29,6 +29,7 @@ model Ad {
|
||||||
passengerDuration Int?
|
passengerDuration Int?
|
||||||
passengerDistance Int?
|
passengerDistance Int?
|
||||||
waypoints Unsupported("geography(LINESTRING)")?
|
waypoints Unsupported("geography(LINESTRING)")?
|
||||||
|
pause Boolean @default(false)
|
||||||
direction Unsupported("geography(LINESTRING)")?
|
direction Unsupported("geography(LINESTRING)")?
|
||||||
fwdAzimuth Int
|
fwdAzimuth Int
|
||||||
backAzimuth Int
|
backAzimuth Int
|
||||||
|
|
|
@ -52,6 +52,7 @@ export class AdMapper
|
||||||
seatsProposed: copy.seatsProposed,
|
seatsProposed: copy.seatsProposed,
|
||||||
seatsRequested: copy.seatsRequested,
|
seatsRequested: copy.seatsRequested,
|
||||||
strict: copy.strict,
|
strict: copy.strict,
|
||||||
|
pause: copy.pause,
|
||||||
driverDuration: copy.driverDuration,
|
driverDuration: copy.driverDuration,
|
||||||
driverDistance: copy.driverDistance,
|
driverDistance: copy.driverDistance,
|
||||||
passengerDuration: copy.passengerDuration,
|
passengerDuration: copy.passengerDuration,
|
||||||
|
@ -100,6 +101,7 @@ export class AdMapper
|
||||||
seatsProposed: record.seatsProposed,
|
seatsProposed: record.seatsProposed,
|
||||||
seatsRequested: record.seatsRequested,
|
seatsRequested: record.seatsRequested,
|
||||||
strict: record.strict,
|
strict: record.strict,
|
||||||
|
pause: record.pause,
|
||||||
driverDuration: record.driverDuration,
|
driverDuration: record.driverDuration,
|
||||||
driverDistance: record.driverDistance,
|
driverDistance: record.driverDistance,
|
||||||
passengerDuration: record.passengerDuration,
|
passengerDuration: record.passengerDuration,
|
||||||
|
|
|
@ -15,6 +15,7 @@ export class CreateAdCommand extends Command implements UserAd {
|
||||||
readonly seatsRequested: number;
|
readonly seatsRequested: number;
|
||||||
readonly strict: boolean;
|
readonly strict: boolean;
|
||||||
readonly waypoints: Address[];
|
readonly waypoints: Address[];
|
||||||
|
readonly pause: boolean;
|
||||||
|
|
||||||
constructor(props: CommandProps<CreateAdCommand>) {
|
constructor(props: CommandProps<CreateAdCommand>) {
|
||||||
super(props);
|
super(props);
|
||||||
|
@ -29,5 +30,6 @@ export class CreateAdCommand extends Command implements UserAd {
|
||||||
this.seatsRequested = props.seatsRequested;
|
this.seatsRequested = props.seatsRequested;
|
||||||
this.strict = props.strict;
|
this.strict = props.strict;
|
||||||
this.waypoints = props.waypoints;
|
this.waypoints = props.waypoints;
|
||||||
|
this.pause = props.pause;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ export class MatchQuery extends QueryBase {
|
||||||
seatsProposed?: number;
|
seatsProposed?: number;
|
||||||
seatsRequested?: number;
|
seatsRequested?: number;
|
||||||
strict?: boolean;
|
strict?: boolean;
|
||||||
|
pause?: boolean;
|
||||||
readonly waypoints: Waypoint[];
|
readonly waypoints: Waypoint[];
|
||||||
excludedAdId?: string;
|
excludedAdId?: string;
|
||||||
algorithmType?: AlgorithmType;
|
algorithmType?: AlgorithmType;
|
||||||
|
|
|
@ -143,6 +143,7 @@ export class PassengerOrientedSelector extends Selector {
|
||||||
|
|
||||||
private _createWhere = (role: Role): string =>
|
private _createWhere = (role: Role): string =>
|
||||||
[
|
[
|
||||||
|
this._wherePause(), // TODO where clause should be ordered for db index optimisation ...
|
||||||
this._whereRole(role),
|
this._whereRole(role),
|
||||||
this._whereStrict(),
|
this._whereStrict(),
|
||||||
this._whereDate(role),
|
this._whereDate(role),
|
||||||
|
@ -157,6 +158,8 @@ export class PassengerOrientedSelector extends Selector {
|
||||||
private _whereRole = (role: Role): string =>
|
private _whereRole = (role: Role): string =>
|
||||||
role == Role.PASSENGER ? 'driver=True' : 'passenger=True';
|
role == Role.PASSENGER ? 'driver=True' : 'passenger=True';
|
||||||
|
|
||||||
|
private _wherePause = (): string => 'pause=False'; // TODO: find if we want to add this as parameter/config or not
|
||||||
|
|
||||||
private _whereStrict = (): string =>
|
private _whereStrict = (): string =>
|
||||||
this.query.strict
|
this.query.strict
|
||||||
? this.query.frequency == Frequency.PUNCTUAL
|
? this.query.frequency == Frequency.PUNCTUAL
|
||||||
|
|
|
@ -81,6 +81,7 @@ export class AdFactory {
|
||||||
seatsProposed: ad.seatsProposed,
|
seatsProposed: ad.seatsProposed,
|
||||||
seatsRequested: ad.seatsRequested,
|
seatsRequested: ad.seatsRequested,
|
||||||
strict: ad.strict,
|
strict: ad.strict,
|
||||||
|
pause: ad.pause,
|
||||||
waypoints: ad.waypoints,
|
waypoints: ad.waypoints,
|
||||||
points: points!,
|
points: points!,
|
||||||
driverDistance,
|
driverDistance,
|
||||||
|
|
|
@ -15,6 +15,7 @@ export interface UserAd {
|
||||||
seatsProposed: number;
|
seatsProposed: number;
|
||||||
seatsRequested: number;
|
seatsRequested: number;
|
||||||
strict: boolean;
|
strict: boolean;
|
||||||
|
pause: boolean;
|
||||||
waypoints: PointProps[];
|
waypoints: PointProps[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +30,7 @@ export interface AdProps {
|
||||||
seatsProposed: number;
|
seatsProposed: number;
|
||||||
seatsRequested: number;
|
seatsRequested: number;
|
||||||
strict: boolean;
|
strict: boolean;
|
||||||
|
pause: boolean;
|
||||||
driverDuration?: number;
|
driverDuration?: number;
|
||||||
driverDistance?: number;
|
driverDistance?: number;
|
||||||
passengerDuration?: number;
|
passengerDuration?: number;
|
||||||
|
@ -51,6 +53,7 @@ export interface CreateAdProps {
|
||||||
seatsProposed: number;
|
seatsProposed: number;
|
||||||
seatsRequested: number;
|
seatsRequested: number;
|
||||||
strict: boolean;
|
strict: boolean;
|
||||||
|
pause: boolean;
|
||||||
waypoints: PointProps[];
|
waypoints: PointProps[];
|
||||||
driverDuration?: number;
|
driverDuration?: number;
|
||||||
driverDistance?: number;
|
driverDistance?: number;
|
||||||
|
|
|
@ -20,6 +20,7 @@ export type AdModel = {
|
||||||
seatsProposed: number;
|
seatsProposed: number;
|
||||||
seatsRequested: number;
|
seatsRequested: number;
|
||||||
strict: boolean;
|
strict: boolean;
|
||||||
|
pause: boolean;
|
||||||
driverDuration?: number;
|
driverDuration?: number;
|
||||||
driverDistance?: number;
|
driverDistance?: number;
|
||||||
passengerDuration?: number;
|
passengerDuration?: number;
|
||||||
|
@ -158,6 +159,7 @@ export class AdRepository
|
||||||
seatsProposed: ungroupedAd.seatsProposed,
|
seatsProposed: ungroupedAd.seatsProposed,
|
||||||
seatsRequested: ungroupedAd.seatsRequested,
|
seatsRequested: ungroupedAd.seatsRequested,
|
||||||
strict: ungroupedAd.strict,
|
strict: ungroupedAd.strict,
|
||||||
|
pause: ungroupedAd.pause,
|
||||||
driverDuration: ungroupedAd.driverDuration,
|
driverDuration: ungroupedAd.driverDuration,
|
||||||
driverDistance: ungroupedAd.driverDistance,
|
driverDistance: ungroupedAd.driverDistance,
|
||||||
passengerDuration: ungroupedAd.passengerDuration,
|
passengerDuration: ungroupedAd.passengerDuration,
|
||||||
|
|
|
@ -32,6 +32,7 @@ export class AdCreatedMessageHandler {
|
||||||
seatsRequested: createdAd.seatsRequested,
|
seatsRequested: createdAd.seatsRequested,
|
||||||
strict: createdAd.strict,
|
strict: createdAd.strict,
|
||||||
waypoints: createdAd.waypoints,
|
waypoints: createdAd.waypoints,
|
||||||
|
pause: createdAd.pause,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ export type Ad = AdReference & {
|
||||||
seatsRequested: number;
|
seatsRequested: number;
|
||||||
strict: boolean;
|
strict: boolean;
|
||||||
waypoints: Waypoint[];
|
waypoints: Waypoint[];
|
||||||
|
pause: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ScheduleItem = {
|
export type ScheduleItem = {
|
||||||
|
|
|
@ -54,6 +54,7 @@ function createAdPropsDefaults(): CreateAdProps {
|
||||||
seatsProposed: 1,
|
seatsProposed: 1,
|
||||||
seatsRequested: 1,
|
seatsRequested: 1,
|
||||||
strict: false,
|
strict: false,
|
||||||
|
pause: false,
|
||||||
waypoints: [],
|
waypoints: [],
|
||||||
points: [],
|
points: [],
|
||||||
driverDuration: 0,
|
driverDuration: 0,
|
||||||
|
|
|
@ -37,6 +37,7 @@ const adEntity: AdEntity = new AdEntity({
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
strict: false,
|
strict: false,
|
||||||
|
pause: false,
|
||||||
seatsProposed: 3,
|
seatsProposed: 3,
|
||||||
seatsRequested: 1,
|
seatsRequested: 1,
|
||||||
driverDistance: 350101,
|
driverDistance: 350101,
|
||||||
|
@ -89,6 +90,7 @@ const adReadModel: AdReadModel = {
|
||||||
fwdAzimuth: 273,
|
fwdAzimuth: 273,
|
||||||
backAzimuth: 93,
|
backAzimuth: 93,
|
||||||
strict: false,
|
strict: false,
|
||||||
|
pause: false,
|
||||||
seatsProposed: 3,
|
seatsProposed: 3,
|
||||||
seatsRequested: 1,
|
seatsRequested: 1,
|
||||||
createdAt: now,
|
createdAt: now,
|
||||||
|
|
|
@ -28,6 +28,7 @@ export function createAdProps(): CreateAdProps {
|
||||||
seatsProposed: 3,
|
seatsProposed: 3,
|
||||||
seatsRequested: 1,
|
seatsRequested: 1,
|
||||||
strict: false,
|
strict: false,
|
||||||
|
pause: false,
|
||||||
waypoints: [originPointProps, destinationPointProps],
|
waypoints: [originPointProps, destinationPointProps],
|
||||||
driverDistance: 23000,
|
driverDistance: 23000,
|
||||||
driverDuration: 900,
|
driverDuration: 900,
|
||||||
|
|
|
@ -37,6 +37,7 @@ const createAdProps: CreateAdProps = {
|
||||||
seatsProposed: 3,
|
seatsProposed: 3,
|
||||||
seatsRequested: 1,
|
seatsRequested: 1,
|
||||||
strict: false,
|
strict: false,
|
||||||
|
pause: false,
|
||||||
frequency: Frequency.PUNCTUAL,
|
frequency: Frequency.PUNCTUAL,
|
||||||
waypoints: [originWaypoint, destinationWaypoint],
|
waypoints: [originWaypoint, destinationWaypoint],
|
||||||
driverDistance: 23000,
|
driverDistance: 23000,
|
||||||
|
|
|
@ -88,6 +88,7 @@ const mockPrismaService = {
|
||||||
seatsProposed: 3,
|
seatsProposed: 3,
|
||||||
seatsRequested: 1,
|
seatsRequested: 1,
|
||||||
strict: false,
|
strict: false,
|
||||||
|
pause: false,
|
||||||
driverDistance: 350000,
|
driverDistance: 350000,
|
||||||
driverDuration: 14400,
|
driverDuration: 14400,
|
||||||
passengerDistance: 350000,
|
passengerDistance: 350000,
|
||||||
|
|
Loading…
Reference in New Issue