mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 22:25:42 +00:00
Search schedule update
This commit is contained in:
@@ -153,8 +153,8 @@ export class SearchService {
|
||||
nationality?: string,
|
||||
) {
|
||||
const [y, m, d] = dateStr.split('-').map(Number);
|
||||
const requestedDate = new Date(y, m - 1, d, 0, 0, 0, 0);
|
||||
const requestedNextDay = new Date(y, m - 1, d + 1, 0, 0, 0, 0);
|
||||
const requestedDate = new Date(`${String(y)}-${String(m).padStart(2,'0')}-${String(d).padStart(2,'0')}T00:00:00+03:00`);
|
||||
const requestedNextDay = new Date(`${String(y)}-${String(m).padStart(2,'0')}-${String(d + 1).padStart(2,'0')}T00:00:00+03:00`);
|
||||
const now = new Date();
|
||||
const totalPassengers = adultCount + (childCount ?? 0);
|
||||
const NEEDED = 3;
|
||||
@@ -213,14 +213,15 @@ export class SearchService {
|
||||
nationality?: string,
|
||||
) {
|
||||
const [y, m, d] = dateStr.split('-').map(Number);
|
||||
const date = new Date(y, m - 1, d, 0, 0, 0, 0);
|
||||
const nextDay = new Date(y, m - 1, d + 1, 0, 0, 0, 0);
|
||||
const date = new Date(`${String(y)}-${String(m).padStart(2,'0')}-${String(d).padStart(2,'0')}T00:00:00+03:00`);
|
||||
const nextDay = new Date(`${String(y)}-${String(m).padStart(2,'0')}-${String(d + 1).padStart(2,'0')}T00:00:00+03:00`);
|
||||
const now = new Date();
|
||||
const totalPassengers = adultCount + (childCount ?? 0);
|
||||
|
||||
const cutoffHours = await this.getCutoffHours();
|
||||
const cutoffThreshold = new Date(now.getTime() + cutoffHours * 60 * 60 * 1000);
|
||||
const isToday = now.getFullYear() === y && now.getMonth() === m - 1 && now.getDate() === d;
|
||||
const nowInEAT = new Date(now.toLocaleString('en-US', { timeZone: 'Africa/Addis_Ababa' }));
|
||||
const isToday = nowInEAT.getFullYear() === y && nowInEAT.getMonth() === m - 1 && nowInEAT.getDate() === d;
|
||||
const earliest = isToday ? cutoffThreshold : date;
|
||||
|
||||
const schedules = await this.prisma.trainSchedule.findMany({
|
||||
@@ -255,8 +256,8 @@ export class SearchService {
|
||||
nationality?: string,
|
||||
) {
|
||||
const [y, m, d] = dateStr.split('-').map(Number);
|
||||
const dayStart = new Date(y, m - 1, d, 0, 0, 0, 0);
|
||||
const dayEnd = new Date(y, m - 1, d + 1, 0, 0, 0, 0);
|
||||
const dayStart = new Date(`${String(y)}-${String(m).padStart(2,'0')}-${String(d).padStart(2,'0')}T00:00:00+03:00`);
|
||||
const dayEnd = new Date(`${String(y)}-${String(m).padStart(2,'0')}-${String(d + 1).padStart(2,'0')}T00:00:00+03:00`);
|
||||
const leg2WindowEnd = new Date(dayEnd.getTime() + this.MAX_CONNECTION_MINUTES * 60_000);
|
||||
const totalPassengers = adultCount + (childCount ?? 0);
|
||||
|
||||
@@ -442,8 +443,8 @@ export class SearchService {
|
||||
}
|
||||
|
||||
const coachTypes = this.buildCoachTypeDetails(schedule, faresByClass, nationality, availabilityByClass);
|
||||
const legDepartureAt = originStop.plannedDepartureAt ?? schedule.departureAt;
|
||||
const legArrivalAt = destStop.plannedArrivalAt ?? schedule.arrivalAt;
|
||||
const legDepartureAt = schedule.departureAt;
|
||||
const legArrivalAt = schedule.arrivalAt;
|
||||
|
||||
const displayCurrency = faresByClass[0]?.displayCurrency ?? resolveCurrencyFromNationality(nationality);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user