mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-25 06:13:04 +00:00
fix(mail-ingest): compare look-alike bookings at their wall time on any server zone
The window around a booking's start went through the host time zone, so on a server outside UTC it missed a booking at the same local time and added it twice.
This commit is contained in:
@@ -260,7 +260,9 @@ export class MailIngestProcessService {
|
||||
}
|
||||
|
||||
private async looksAlike(tripId: number, draft: MailDraft): Promise<boolean> {
|
||||
const start = Date.parse(bookingStart(draft.item) ?? '');
|
||||
// A wall time without a zone, compared as text: shifted as UTC, it stays that wall time.
|
||||
const wall = /^(\d{4}-\d{2}-\d{2})(?:T(\d{2}:\d{2}))?/.exec(bookingStart(draft.item) ?? '');
|
||||
const start = wall ? Date.parse(`${wall[1]}T${wall[2] ?? '00:00'}:00Z`) : Number.NaN;
|
||||
const window = (offset: number) =>
|
||||
Number.isFinite(start) ? new Date(start + offset).toISOString().slice(0, 16) : null;
|
||||
return this.candidates.tripHasSimilar(tripId, {
|
||||
|
||||
Reference in New Issue
Block a user