Skip to content

Commit

Permalink
only query draft trips in the dateRange
Browse files Browse the repository at this point in the history
Up to this point, we have been querying all unprocessed/draft trips from pipelineRange start up to the endTs.
This unifies the start ts for both queries. (the end ts still differs because unprocessed trips could exist after the pipeline end, while processed trips will always be before pipeline end).

If for some reason there's an unprocessed trip older than the daterange start, it won't be included in the timeline anymore.
  • Loading branch information
JGreenlee committed Apr 2, 2024
1 parent 5ae3ea8 commit 00c655c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions www/js/TimelineContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,12 @@ export const useTimelineContext = (): ContextProps => {
if (!pipelineRange?.start_ts || !pipelineRange?.end_ts)
return logWarn('No pipelineRange yet - early return');
logDebug('Timeline: fetchTripsInRange from ' + dateRange[0] + ' to ' + dateRange[1]);
const [startTs, endTs] = isoDateRangeToTsRange(dateRange);

const readCompositePromise = readAllCompositeTrips(
Math.max(startTs, pipelineRange.start_ts), // ensure that we don't read before the pipeline start
Math.min(endTs, pipelineRange.end_ts), // ensure that we don't read after the pipeline end
);
const [startTs, endTs] = isoDateRangeToTsRange(dateRange);
const maxStartTs = Math.max(startTs, pipelineRange.start_ts); // ensure that we don't read before the pipeline start
const minEndTs = Math.min(endTs, pipelineRange.end_ts); // ensure that we don't read after the pipeline end

const readCompositePromise = readAllCompositeTrips(maxStartTs, minEndTs);
let readUnprocessedPromise;
if (endTs >= pipelineRange.end_ts) {
let lastProcessedTrip: CompositeTrip | undefined;
Expand All @@ -231,7 +230,7 @@ export const useTimelineContext = (): ContextProps => {
.reverse()
.find((trip) => trip.origin_key.includes('trip')) as CompositeTrip;
}
readUnprocessedPromise = readUnprocessedTrips(pipelineRange.end_ts, endTs, lastProcessedTrip);
readUnprocessedPromise = readUnprocessedTrips(maxStartTs, endTs, lastProcessedTrip);
} else {
readUnprocessedPromise = Promise.resolve([]);
}
Expand Down

0 comments on commit 00c655c

Please sign in to comment.