set schedule to optional in match query and query handler

This commit is contained in:
Sylvain Briat 2024-03-28 17:16:51 +01:00 committed by sbriat
parent 4fd2950027
commit 6b9bf53b4a
2 changed files with 5 additions and 3 deletions

View File

@ -165,7 +165,7 @@ export class MatchQueryHandler implements IQueryHandler {
frequency: query.frequency, frequency: query.frequency,
fromDate: query.fromDate, fromDate: query.fromDate,
toDate: query.toDate, toDate: query.toDate,
schedule: query.schedule.map((scheduleItem: ScheduleItem) => ({ schedule: query.schedule?.map((scheduleItem: ScheduleItem) => ({
day: scheduleItem.day as number, day: scheduleItem.day as number,
time: scheduleItem.time, time: scheduleItem.time,
margin: scheduleItem.margin as number, margin: scheduleItem.margin as number,

View File

@ -21,7 +21,7 @@ export class MatchQuery extends QueryBase {
readonly frequency: Frequency; readonly frequency: Frequency;
fromDate: string; fromDate: string;
toDate: string; toDate: string;
schedule: ScheduleItem[]; schedule?: ScheduleItem[];
seatsProposed?: number; seatsProposed?: number;
seatsRequested?: number; seatsRequested?: number;
strict?: boolean; strict?: boolean;
@ -73,7 +73,7 @@ export class MatchQuery extends QueryBase {
} }
setMissingMarginDurations = (defaultMarginDuration: number): MatchQuery => { setMissingMarginDurations = (defaultMarginDuration: number): MatchQuery => {
this.schedule.forEach((day: ScheduleItem) => { this.schedule?.forEach((day: ScheduleItem) => {
if (day.margin === undefined) day.margin = defaultMarginDuration; if (day.margin === undefined) day.margin = defaultMarginDuration;
}); });
return this; return this;
@ -136,6 +136,8 @@ export class MatchQuery extends QueryBase {
setDatesAndSchedule = ( setDatesAndSchedule = (
datetimeTransformer: DateTimeTransformerPort, datetimeTransformer: DateTimeTransformerPort,
): MatchQuery => { ): MatchQuery => {
// no transformation if schedule is not set
if (this.schedule === undefined) return this;
const initialFromDate: string = this.fromDate; const initialFromDate: string = this.fromDate;
this.fromDate = datetimeTransformer.fromDate( this.fromDate = datetimeTransformer.fromDate(
{ {