@transportme/load-ptv-gtfs 1.4.11 → 1.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,9 +8,9 @@ import { minutesPastMidnightToHHMM } from '../utils.mjs'
8
8
 
9
9
  export default class TripLoader {
10
10
 
11
- #routes
12
- #stops
13
- #trips
11
+ routes
12
+ stops
13
+ trips
14
14
 
15
15
  #tripsReader
16
16
  #stopTimesReader
@@ -44,9 +44,9 @@ export default class TripLoader {
44
44
  * @param {DatabaseConnection} database A database connection
45
45
  */
46
46
  constructor({ tripsFile, stopTimesFile, calendarFile, calendarDatesFile }, mode, database) {
47
- this.#routes = this.getRoutesDB(database)
48
- this.#stops = this.getStopsDB(database)
49
- this.#trips = this.getTripsDB(database)
47
+ this.routes = this.getRoutesDB(database)
48
+ this.stops = this.getStopsDB(database)
49
+ this.trips = this.getTripsDB(database)
50
50
 
51
51
  this.#mode = mode
52
52
 
@@ -104,7 +104,7 @@ export default class TripLoader {
104
104
  async findMatchingRoute(routeGTFSID) {
105
105
  if (this.#routeCache[routeGTFSID]) return this.#routeCache[routeGTFSID]
106
106
 
107
- let route = await this.#routes.findDocument({
107
+ let route = await this.routes.findDocument({
108
108
  routeGTFSID: routeGTFSID
109
109
  })
110
110
 
@@ -115,7 +115,7 @@ export default class TripLoader {
115
115
  async findMatchingStop(stopGTFSID) {
116
116
  if (this.#stopCache[stopGTFSID]) return this.#stopCache[stopGTFSID]
117
117
 
118
- let stop = await this.#stops.findDocument({
118
+ let stop = await this.stops.findDocument({
119
119
  'bays.stopGTFSID': stopGTFSID
120
120
  })
121
121
 
@@ -247,13 +247,20 @@ export default class TripLoader {
247
247
  await this.writeTrips()
248
248
  }
249
249
 
250
- async writeTrips() {
251
- if (this.#tripsToLoad.length) {
252
- this.#routeCache = {}
253
- this.#stopCache = {}
250
+ getTripsToLoad() {
251
+ return this.#tripsToLoad
252
+ }
254
253
 
255
- await this.#trips.createDocuments(this.#tripsToLoad)
256
- this.#tripsToLoad = []
254
+ clearTripsToLoad() {
255
+ this.#routeCache = {}
256
+ this.#stopCache = {}
257
+ this.#tripsToLoad = []
258
+ }
259
+
260
+ async writeTrips() {
261
+ if (this.getTripsToLoad().length) {
262
+ await this.trips.createDocuments(this.getTripsToLoad())
263
+ this.clearTripsToLoad()
257
264
  }
258
265
  }
259
266
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transportme/load-ptv-gtfs",
3
- "version": "1.4.11",
3
+ "version": "1.4.13",
4
4
  "description": "",
5
5
  "main": "index.mjs",
6
6
  "scripts": {