Skip to content

Commit

Permalink
Do not set delays on historic records adn properly close LevelDBs
Browse files Browse the repository at this point in the history
  • Loading branch information
julianrojas87 committed Jul 8, 2022
1 parent ecf6fc1 commit 4592a21
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
14 changes: 8 additions & 6 deletions lib/stoptimes/StopTimes2Cxs.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,20 @@ module.exports = function (sourcePath, outPath, stores, fresh) {
printedRows++;
});

connectionRules.on('end', () => {
connectionRules.on('end', async () => {
for (let i in connectionsPool) {
connectionsPool[i].end();
}

// Close all LevelDB stores as they will not be used any further on this process
if (!(stores.stopsDB instanceof Map)) {
stores.stopsDB.close();
stores.tripsDB.close();
stores.routesDB.close();
stores.servicesDB.close();
historyDB.close();
await Promise.all([
stores.stopsDB.close(),
stores.tripsDB.close(),
stores.routesDB.close(),
stores.servicesDB.close(),
historyDB.close()
]);
}

console.error(`Created ${printedRows} Connection rules in ${new Date() - t0} ms`);
Expand Down
6 changes: 1 addition & 5 deletions lib/stoptimes/st2c.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@
// Update history with new found service dates
const update = Object.assign({}, old);
newServices.forEach(nsd => {
update[nsd] = {
type: 'Connection',
departureDelay: 0,
arrivalDelay: 0
}
update[nsd] = { type: 'Connection' };
});

await this.historyDB.put(id, update);
Expand Down

0 comments on commit 4592a21

Please sign in to comment.