Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/datasources/HFPDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class HFPDataSource extends SQLDataSource {
SELECT DISTINCT ON (unique_vehicle_id) unique_vehicle_id,
vehicle_number,
owner_operator_id
FROM otherevent
FROM otherevent_all
WHERE tst >= :minTime
AND tst < :maxTime
AND event_type = 'VJA'
Expand Down Expand Up @@ -224,7 +224,7 @@ SELECT journey_type,
long,
loc,
mode
FROM otherevent
FROM otherevent_all
WHERE tst >= :minTime
AND tst <= :maxTime
AND unique_vehicle_id = :vehicleId
Expand Down Expand Up @@ -280,10 +280,10 @@ ORDER BY tst DESC;
)
}

const queries = [this.getBatched(createQuery('vehicleposition'))]
const queries = [this.getBatched(createQuery('vehicleposition_all'))]

if (unsignedEvents) {
queries.push(this.getBatched(createQuery('unsignedevent')))
queries.push(this.getBatched(createQuery('unsignedevent_all')))
}

return Promise.all(queries).then(([vp = [], unsigned = []]) =>
Expand All @@ -309,7 +309,7 @@ ORDER BY tst DESC;

const eventsQuery = this.db.raw(
`SELECT ${vehicleFields.join(',')}
FROM stopevent
FROM stopevent_all
WHERE tst >= :minTime
AND tst <= :maxTime
AND event_type IN ('DEP', 'PDE')
Expand All @@ -320,7 +320,7 @@ ORDER BY tst ASC;
{ date, minTime, maxTime, vehicleId: queryVehicleId }
)

const legacyQuery = this.db('vehicleposition')
const legacyQuery = this.db('vehicleposition_all')
.select(vehicleFields)
.whereBetween('tst', [minTime, maxTime])
.where('journey_type', 'journey')
Expand Down Expand Up @@ -352,7 +352,7 @@ ORDER BY tst ASC;

const query = this.db.raw(
`SELECT ${routeJourneyFields.join(',')}
FROM vehicleposition
FROM vehicleposition_all
WHERE tst >= :minTime
AND tst <= :maxTime
AND geohash_level <= 3
Expand Down Expand Up @@ -425,9 +425,9 @@ ORDER BY tst ASC;
}

const queries = [
createQuery('vehicleposition', vehicleFields),
createQuery('stopevent', vehicleFields),
createQuery('otherevent', vehicleFields),
createQuery('vehicleposition_all', vehicleFields),
createQuery('stopevent_all', vehicleFields),
createQuery('otherevent_all', vehicleFields),
createQuery('lightpriorityevent', [...vehicleFields, ...tlpEventFields]),
]

Expand Down Expand Up @@ -470,7 +470,7 @@ ORDER BY tst ASC;
async getDepartureEvents(stopIds: string[], date: string): Promise<Vehicles[]> {
const { minTime, maxTime } = createTstRange(date)

const legacyQuery = this.db('vehicleposition')
const legacyQuery = this.db('vehicleposition_all')
.select(
this.db.raw(
`DISTINCT ON ("journey_start_time", "unique_vehicle_id") ${vehicleFields.join(',')}`
Expand All @@ -489,7 +489,7 @@ ORDER BY tst ASC;
const eventsQuery = this.db.raw(
`
SELECT ${routeDepartureFields.join(',')}
FROM stopevent
FROM stopevent_all
WHERE tst >= :minTime
AND tst <= :maxTime
AND event_type IN ('DEP', 'PDE', 'PAS')
Expand Down Expand Up @@ -527,7 +527,7 @@ ORDER BY tst DESC;
): Promise<Vehicles[]> {
const { minTime, maxTime } = createTstRange(date)

const legacyQuery = this.db('vehicleposition')
const legacyQuery = this.db('vehicleposition_all')
.select(
this.db.raw(
`DISTINCT ON ("journey_start_time", "unique_vehicle_id") ${routeDepartureFields.join(
Expand Down Expand Up @@ -556,7 +556,7 @@ ORDER BY tst DESC;

const eventsQuery = this.db.raw(
`SELECT ${routeDepartureFields.join(',')}
FROM stopevent
FROM stopevent_all
WHERE tst >= :minTime
AND tst <= :maxTime
AND event_type IN ('${queryEventTypes.join(`','`)}')
Expand Down Expand Up @@ -594,7 +594,7 @@ ORDER BY tst DESC;
const query = this.db.raw(
`
SELECT ${unsignedEventFields.join(',')}
FROM unsignedevent
FROM unsignedevent_all
WHERE tst >= :minTime AND tst <= :maxTime
AND unique_vehicle_id = :vehicleId
ORDER BY tst DESC;
Expand Down