modules/query/HolidayTable.js
function getHoliday(db, date, callback) {

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

  // Build the select statement
  let select = "SELECT date, holiday_name, peak, service_info " +
    "FROM rt_holidays WHERE date=" + date;

  // Query the database
  db.get(select, function(err, result) {

    // Database Query Error
    if ( err ) {
      return callback(err);
    }

    // Holiday to return
    let holiday = undefined;

    // Holiday was found...
    if ( result !== undefined ) {

      // Build the Holiday
      holiday = new Holiday(
        result.date,
        result.holiday_name,
        result.peak === 1,
        result.service_info
      );

    }

    // Add holiday to cache
    cache_holidayByDate.put(cacheKey, holiday);

    // Return the holiday
    return callback(null, holiday);

  })

}
function getHoliday(db, date, callback) {

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

  // Build the select statement
  let select = "SELECT date, holiday_name, peak, service_info " +
    "FROM rt_holidays WHERE date=" + date;

  // Query the database
  db.get(select, function(err, result) {

    // Database Query Error
    if ( err ) {
      return callback(err);
    }

    // Holiday to return
    let holiday = undefined;

    // Holiday was found...
    if ( result !== undefined ) {

      // Build the Holiday
      holiday = new Holiday(
        result.date,
        result.holiday_name,
        result.peak === 1,
        result.service_info
      );

    }

    // Add holiday to cache
    cache_holidayByDate.put(cacheKey, holiday);

    // Return the holiday
    return callback(null, holiday);

  })

}
function getHoliday ( db , date , callback ) { // Check cache for Holiday let cacheKey = db . id + "-" + date ; let cache = cache_holidayByDate . get ( cacheKey ) ; if ( cache !== null ) { return callback ( null , cache ) ; } // Build the select statement let select = "SELECT date, holiday_name, peak, service_info " + "FROM rt_holidays WHERE date=" + date ; // Query the database db . get ( select , function ( err , result ) { // Database Query Error if ( err ) { return callback ( err ) ; } // Holiday to return let holiday = undefined ; // Holiday was found... if ( result !== undefined ) { // Build the Holiday holiday = new Holiday ( result . date , result . holiday_name , result . peak === 1 , result . service_info ) ; } // Add holiday to cache cache_holidayByDate . put ( cacheKey , holiday ) ; // Return the holiday return callback ( null , holiday ) ; } ) }
Get the Holiday for the specified date or 'undefined' if
there is no holiday on the date

@param {RightTrackDB} db The Right Track DB to query
@param {int} date the date (yyyymmdd)
@param {function} callback Callback function
@param {Error} callback.error Database Query Error
@param {Holiday} [callback.holiday] The selected Holiday
Get the Holiday for the specified date or undefined if there is no holiday on the date