diff --git a/lib/manager/dataset_manager.js b/lib/manager/dataset_manager.js index d5b1974..358b59f 100644 --- a/lib/manager/dataset_manager.js +++ b/lib/manager/dataset_manager.js @@ -216,46 +216,45 @@ export class DatasetManager { const connsPath = `${this.storage}/linked_connections/${companyName}`; logger.info(`Creating ${companyName} Linked Connections...`); - converter.resultStream(uncompressed_feed, connsPath, async rawConns => { - - logger.info(`Sorting and fragmenting ${companyName} Linked Connections...`); - // Create folder for Linked Connection fragments - fs.mkdirSync(`${this.storage}/linked_pages/${companyName}/${file_name}`); - - // Proceed to sort and fragment the Linked Connections graph - const sorted = await this.sortLCByDepartureTime(rawConns); - - sorted.pipe(JsonLParser.parser()) - .pipe(new PageWriterStream(`${this.storage}/linked_pages/${companyName}/${file_name}`, - dataset.fragmentSize || 300)) - .on('finish', async () => { - const t1 = (new Date().getTime() - t0) / 1000; - logger.info(`Dataset conversion for ${companyName} completed successfully (took ${t1} seconds)`); - - // Update Catalog, Stops and Routes - const [stops, routes] = await Promise.all([ - new Stops(uncompressed_feed).createStopList(companyName), - new Routes(uncompressed_feed).createRouteList(companyName), - ]); - await Promise.all([ - writeFile(`${this.storage}/stops/${companyName}/stops.json`, JSON.stringify(stops), 'utf8'), - writeFile(`${this.storage}/routes/${companyName}/routes.json`, JSON.stringify(routes), 'utf8'), - ]); - - const catalog = await new Catalog().createCatalog(companyName); - await writeFile(`${this.storage}/catalog/${companyName}/catalog.json`, JSON.stringify(catalog), 'utf8'), - - logger.info('DCAT catalog updated correctly'); - logger.info(`Stop dataset for ${companyName} updated`); - logger.info(`Route dataset for ${companyName} updated`); - - // Clean up - await del([ - lockPath, - uncompressed_feed, - ], { force: true }); - }); - }); + const rawConns = await converter.convert(uncompressed_feed, connsPath); + + logger.info(`Sorting and fragmenting ${companyName} Linked Connections...`); + // Create folder for Linked Connection fragments + fs.mkdirSync(`${this.storage}/linked_pages/${companyName}/${file_name}`); + + // Proceed to sort and fragment the Linked Connections graph + const sorted = await this.sortLCByDepartureTime(rawConns); + + sorted.pipe(JsonLParser.parser()) + .pipe(new PageWriterStream(`${this.storage}/linked_pages/${companyName}/${file_name}`, + dataset.fragmentSize || 300)) + .on('finish', async () => { + const t1 = (new Date().getTime() - t0) / 1000; + logger.info(`Dataset conversion for ${companyName} completed successfully (took ${t1} seconds)`); + + // Update Catalog, Stops and Routes + const [stops, routes] = await Promise.all([ + new Stops(uncompressed_feed).createStopList(companyName), + new Routes(uncompressed_feed).createRouteList(companyName), + ]); + await Promise.all([ + writeFile(`${this.storage}/stops/${companyName}/stops.json`, JSON.stringify(stops), 'utf8'), + writeFile(`${this.storage}/routes/${companyName}/routes.json`, JSON.stringify(routes), 'utf8'), + ]); + + const catalog = await new Catalog().createCatalog(companyName); + await writeFile(`${this.storage}/catalog/${companyName}/catalog.json`, JSON.stringify(catalog), 'utf8'), + + logger.info('DCAT catalog updated correctly'); + logger.info(`Stop dataset for ${companyName} updated`); + logger.info(`Route dataset for ${companyName} updated`); + + // Clean up + await del([ + lockPath, + uncompressed_feed, + ], { force: true }); + }); } else { logger.warn(companyName + " dataset was already downloaded"); } diff --git a/package-lock.json b/package-lock.json index 8f1fb56..ff4a2b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "linked-connections-server", - "version": "1.4.1", + "version": "1.4.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "linked-connections-server", - "version": "1.4.1", + "version": "1.4.2", "license": "MIT", "dependencies": { "accepts": "^1.3.8", @@ -3210,9 +3210,9 @@ } }, "node_modules/gtfs2lc": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/gtfs2lc/-/gtfs2lc-2.3.0.tgz", - "integrity": "sha512-O6nUtyCJ3/VIevxRWvvsWxoGd10UmEBqGgtnXSOb5Xux1WnC0L/K3QlJFGDMdERGGfh0OhtIFCMQ0780brTnWQ==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/gtfs2lc/-/gtfs2lc-2.3.1.tgz", + "integrity": "sha512-yy1ayGa7NFmo2LDJ+yAaNxKtk9IlKd60gKFSKD2No8Lro0OXXjXowM2/8B8YE8J4AYnIjo1/PFEGGZzE09kMig==", "license": "MIT", "dependencies": { "commander": "^4.1.1", diff --git a/package.json b/package.json index 5be7f0a..7c764c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "linked-connections-server", - "version": "1.4.1", + "version": "1.4.2", "author": "Julian Rojas", "license": "MIT", "type": "module",