changed logic form filter only with start date

This commit is contained in:
paritosh18
2026-04-27 20:02:21 +05:30
parent e6ba52520d
commit 0d18a77ab5
3 changed files with 3 additions and 29 deletions

View File

@@ -485,7 +485,7 @@ saveItineraryActivitySelections:
getAllUserSavedItineraries:
handler: src/modules/user/handlers/itinerary/getAllUserSavedItineraries.handler
memorySize: 512
memorySize: 1024
package:
patterns:
- 'src/modules/user/**'

View File

@@ -60,7 +60,6 @@ export const handler = safeHandler(async (
const itineraryHeaderXidRaw =
event.queryStringParameters?.itineraryHeaderXid ?? null;
const startDateRaw = event.queryStringParameters?.startDate ?? null;
const endDateRaw = event.queryStringParameters?.endDate ?? null;
let itineraryHeaderXid: number | undefined;
if (
@@ -79,38 +78,17 @@ export const handler = safeHandler(async (
startDateRaw !== null &&
startDateRaw !== undefined &&
startDateRaw.trim() !== '';
const hasEndDate =
endDateRaw !== null &&
endDateRaw !== undefined &&
endDateRaw.trim() !== '';
if (hasStartDate !== hasEndDate) {
throw new ApiError(
400,
'startDate and endDate must be provided together',
);
}
let startDate: Date | undefined;
let endDate: Date | undefined;
if (hasStartDate && hasEndDate) {
if (hasStartDate) {
startDate = parseQueryDate(startDateRaw, 'startDate');
endDate = parseQueryDate(endDateRaw, 'endDate');
if (startDate > endDate) {
throw new ApiError(
400,
'startDate must be earlier than or equal to endDate',
);
}
}
const result = await itineraryService.getAllUserSavedItineraries(
userId,
itineraryHeaderXid,
startDate,
endDate,
);
return {

View File

@@ -1801,19 +1801,15 @@ export class ItineraryService {
userXid: number,
itineraryHeaderXid?: number,
startDate?: Date,
endDate?: Date,
) {
const itineraries = await this.prisma.itineraryHeader.findMany({
where: {
...(itineraryHeaderXid ? { id: itineraryHeaderXid } : {}),
...(startDate && endDate
...(startDate
? {
fromDate: {
gte: startDate,
},
toDate: {
lte: endDate,
},
}
: {}),
isActive: true,