modules/query/TripsTable.js
function getTripByShortName(db, shortName, date, callback) {

  // Check Cache for Trip
  let cacheKey = db.id + "-" + shortName + "-" + date;
  let cache = cache_tripsByShortName.get(cacheKey);
  if ( cache !== null ) {
    return callback(null, cache);
  }

  // Get effective service ids
  _buildEffectiveServiceIDString(db, date, function(err, serviceIdString) {
    if ( err ) {
      return callback(err);
    }

    // Get Trip ID
    let select = "SELECT trip_id FROM gtfs_trips WHERE trip_short_name = '" +
      shortName + "' AND service_id IN " + serviceIdString + ";";

    // Query database
    db.get(select, function(err, result) {
      if ( err ) {
        return callback(err);
      }

      // No Trip Found
      if ( result === undefined ) {
        return callback(null, undefined);
      }

      // Get the Trip
      getTrip(db, result.trip_id, date, function(err, trip) {

        // Add Trip to Cache
        cache_tripsByShortName.put(cacheKey, trip);

        // Return Trip
        return callback(err, trip);

      });

    });

  });

}
function getTripByShortName(db, shortName, date, callback) {

  // Check Cache for Trip
  let cacheKey = db.id + "-" + shortName + "-" + date;
  let cache = cache_tripsByShortName.get(cacheKey);
  if ( cache !== null ) {
    return callback(null, cache);
  }

  // Get effective service ids
  _buildEffectiveServiceIDString(db, date, function(err, serviceIdString) {
    if ( err ) {
      return callback(err);
    }

    // Get Trip ID
    let select = "SELECT trip_id FROM gtfs_trips WHERE trip_short_name = '" +
      shortName + "' AND service_id IN " + serviceIdString + ";";

    // Query database
    db.get(select, function(err, result) {
      if ( err ) {
        return callback(err);
      }

      // No Trip Found
      if ( result === undefined ) {
        return callback(null, undefined);
      }

      // Get the Trip
      getTrip(db, result.trip_id, date, function(err, trip) {

        // Add Trip to Cache
        cache_tripsByShortName.put(cacheKey, trip);

        // Return Trip
        return callback(err, trip);

      });

    });

  });

}
function getTripByShortName ( db , shortName , date , callback ) { // Check Cache for Trip let cacheKey = db . id + "-" + shortName + "-" + date ; let cache = cache_tripsByShortName . get ( cacheKey ) ; if ( cache !== null ) { return callback ( null , cache ) ; } // Get effective service ids _buildEffectiveServiceIDString ( db , date , function ( err , serviceIdString ) { if ( err ) { return callback ( err ) ; } // Get Trip ID let select = "SELECT trip_id FROM gtfs_trips WHERE trip_short_name = '" + shortName + "' AND service_id IN " + serviceIdString + ";" ; // Query database db . get ( select , function ( err , result ) { if ( err ) { return callback ( err ) ; } // No Trip Found if ( result === undefined ) { return callback ( null , undefined ) ; } // Get the Trip getTrip ( db , result . trip_id , date , function ( err , trip ) { // Add Trip to Cache cache_tripsByShortName . put ( cacheKey , trip ) ; // Return Trip return callback ( err , trip ) ; } ) ; } ) ; } ) ; }
Get the Trip specified by the Trip short name that operates on the specified date
@param {RightTrackDB} db The Right Track DB to query
@param {string} shortName Trip short name
@param {int} date Date Integer (yyyymmdd)
@param {function} callback Callback function
@param {Error} callback.error Database Query Error
@param {Trip} [callback.trip] The selected Trip
Get the Trip specified by the Trip short name that operates on the specified date