pis #12
@ -10,29 +10,34 @@ const ldbKey = process.env.OWL_LDB_KEY
|
||||
const ldbsvKey = process.env.OWL_LDB_SVKEY
|
||||
|
||||
async function get(id, staff=false){
|
||||
var cleanId = san.cleanApiEndpointTxt(id);
|
||||
var obj = await util.checkCrs(cleanId);
|
||||
const cleanId = san.cleanApiEndpointTxt(id);
|
||||
const obj = await util.checkCrs(cleanId);
|
||||
try {
|
||||
var crs = obj[0]['3ALPHA'];
|
||||
const crs = obj[0]['3ALPHA'];
|
||||
log.out(`ldbService.get: Determined CRS for lookup to be: ${crs}`, "info");
|
||||
var data = arrDepBoard(crs);
|
||||
db.increment("ldbws");
|
||||
await data;
|
||||
if (staff) {
|
||||
const data = arrDepBoardStaff(crs)
|
||||
db.increment("ldbsvws")
|
||||
return await data
|
||||
} else {
|
||||
const data = arrDepBoard(crs);
|
||||
db.increment("ldbws");
|
||||
return await data
|
||||
}
|
||||
} catch (err) {
|
||||
log.out(`ldbService.get: Error, Unable to find CRS: ${err}`, "info")
|
||||
var data = {ERROR:'NOT_FOUND',description:'The entered station was not found. Please check and try again.'};
|
||||
return {ERROR:'NOT_FOUND',description:'The entered station was not found. Please check and try again.'};
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
async function arrDepBoard(CRS){
|
||||
log.out(`ldbService.arrDepBoard: Trying to fetch ArrDep Board for ${CRS}`, "info")
|
||||
try {
|
||||
var options = {
|
||||
const options = {
|
||||
numRows: 10,
|
||||
crs: CRS.toUpperCase()
|
||||
}
|
||||
var api = new ldb(ldbKey,false)
|
||||
const api = new ldb(ldbKey,false)
|
||||
return await api.call("GetArrDepBoardWithDetails", options, false, false)
|
||||
} catch (err) {
|
||||
log.out(`ldbService.arrDepBoard: Lookup Failed for: ${CRS}`, "warn")
|
||||
@ -45,10 +50,11 @@ async function arrDepBoardStaff(CRS) {
|
||||
try {
|
||||
const options = {
|
||||
numRows: 25,
|
||||
crs: CRS.toUpperCase()
|
||||
crs: CRS.toUpperCase(),
|
||||
getNonPassengerServices: true
|
||||
}
|
||||
const api = new ldb(ldbsvKey,true)
|
||||
return await api.call("Unknown") // Need to find out the syntax of this!
|
||||
return await api.call("GetArrDepBoardWithDetails", options, false, false)
|
||||
} catch (err) {
|
||||
log.out(`ldbService.arrDepBoardStaff: Lookup Failed for: ${CRS}, "warn`)
|
||||
return {GetStationBoardResult: "not available", Reason: `The CRS code ${CRS} is not valid`, Why: `Sometimes a station will have more than one CRS - for example Filton Abbey Wood has FIT and FAW however schedules are only available when looking up with FIT - this is how the National Rail Enquiries systems work.`};
|
||||
|
Loading…
Reference in New Issue
Block a user