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,
fromDate: query.fromDate,
toDate: query.toDate,
schedule: query.schedule.map((scheduleItem: ScheduleItem) => ({
schedule: query.schedule?.map((scheduleItem: ScheduleItem) => ({
day: scheduleItem.day as number,
time: scheduleItem.time,
margin: scheduleItem.margin as number,

View File

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