From 16ebe8d5439898c3f7e2b1e93396983ee08a2d8b Mon Sep 17 00:00:00 2001 From: Sylvain Briat Date: Wed, 3 Apr 2024 13:02:31 +0200 Subject: [PATCH] handle excluded ad in query and selector --- src/modules/ad/core/application/queries/match/match.query.ts | 2 ++ .../queries/match/selector/passenger-oriented.selector.ts | 4 ++++ .../ad/tests/unit/core/passenger-oriented-selector.spec.ts | 1 + 3 files changed, 7 insertions(+) diff --git a/src/modules/ad/core/application/queries/match/match.query.ts b/src/modules/ad/core/application/queries/match/match.query.ts index e5fda6f..8e41752 100644 --- a/src/modules/ad/core/application/queries/match/match.query.ts +++ b/src/modules/ad/core/application/queries/match/match.query.ts @@ -26,6 +26,7 @@ export class MatchQuery extends QueryBase { seatsRequested?: number; strict?: boolean; readonly waypoints: Waypoint[]; + excludedAdId?: string; algorithmType?: AlgorithmType; remoteness?: number; useProportion?: boolean; @@ -56,6 +57,7 @@ export class MatchQuery extends QueryBase { this.seatsRequested = props.seatsRequested; this.strict = props.strict; this.waypoints = props.waypoints; + this.excludedAdId = props.excludedAdId; this.algorithmType = props.algorithmType; this.remoteness = props.remoteness; this.useProportion = props.useProportion; diff --git a/src/modules/ad/core/application/queries/match/selector/passenger-oriented.selector.ts b/src/modules/ad/core/application/queries/match/selector/passenger-oriented.selector.ts index 2239f0d..baea02b 100644 --- a/src/modules/ad/core/application/queries/match/selector/passenger-oriented.selector.ts +++ b/src/modules/ad/core/application/queries/match/selector/passenger-oriented.selector.ts @@ -136,6 +136,7 @@ export class PassengerOrientedSelector extends Selector { this._whereStrict(), this._whereDate(), this._whereSchedule(role), + this._whereExcludedAd(), this._whereAzimuth(), this._whereProportion(role), this._whereRemoteness(role), @@ -206,6 +207,9 @@ export class PassengerOrientedSelector extends Selector { return ''; }; + private _whereExcludedAd = (): string => + this.query.excludedAdId ? `ad.uuid <> '${this.query.excludedAdId}'` : ''; + private _wherePassengerSchedule = ( date: Date, scheduleItem: ScheduleItem, diff --git a/src/modules/ad/tests/unit/core/passenger-oriented-selector.spec.ts b/src/modules/ad/tests/unit/core/passenger-oriented-selector.spec.ts index 7cd83b8..f1b00ff 100644 --- a/src/modules/ad/tests/unit/core/passenger-oriented-selector.spec.ts +++ b/src/modules/ad/tests/unit/core/passenger-oriented-selector.spec.ts @@ -47,6 +47,7 @@ const matchQuery = new MatchQuery( ], strict: false, waypoints: [originWaypoint, destinationWaypoint], + excludedAdId: '758618c6-dd82-4199-a548-0205161b04d7', }, bareMockGeorouter, );