Feature Complete:
- MongoDB Check before Initialising - Output to file or S3 - Output to correct format for JSON Schema
This commit is contained in:
@@ -2,10 +2,17 @@ import { Readable } from 'node:stream';
|
||||
import { createInterface } from 'node:readline';
|
||||
import XXH from 'xxhashjs';
|
||||
import { log } from './logger.js';
|
||||
import { DataIngressPisData } from '@owlboard/backend-data-contracts';
|
||||
|
||||
const BASE_URL = process.env.BASEURL || 'https://owlboard.info'
|
||||
|
||||
// Local cache crs, tiploc mappings to reduce API hits to once per CRS
|
||||
const tiplocCache = new Map<string, string>();
|
||||
|
||||
// To align with generating the hash in Go if needed for lookups
|
||||
const SEED = 0;
|
||||
|
||||
// Type for the data input
|
||||
interface InputRecord {
|
||||
code: string;
|
||||
stops: string[];
|
||||
@@ -33,14 +40,16 @@ export async function* processPisStream(inputStream: Readable) {
|
||||
const crsHash = XXH.h64(record.stops.join('|'), SEED);
|
||||
const tiplocStops = await mapStopsToTiploc(record.stops);
|
||||
const tiplocHash = XXH.h64(tiplocStops.join('|'), SEED);
|
||||
yield {
|
||||
|
||||
const data: DataIngressPisData.PisObjects = {
|
||||
code: record.code,
|
||||
toc: TOC.toLowerCase(),
|
||||
crsStops: record.stops,
|
||||
crsHash: crsHash.toString(10),
|
||||
crsHash: crsHash.toString(),
|
||||
tiplocStops: tiplocStops,
|
||||
tiplocHash: tiplocHash.toString(10),
|
||||
tiplocHash: tiplocHash.toString(),
|
||||
}
|
||||
yield data;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user