Prepare for PIS Search upgrade
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
0a25ae85f5
commit
90baf1b13a
@ -7,7 +7,7 @@ import { logger } from "../utils/logger.utils";
|
|||||||
|
|
||||||
const supported = ["GW", "UK"];
|
const supported = ["GW", "UK"];
|
||||||
|
|
||||||
async function findPisByOrigDest(start, end) {
|
async function findPisByOrigDest(start: string, end: string) {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`pisServices.findPisByOrigDest: Searching for Orig: ${start}, Dest: ${end}`
|
`pisServices.findPisByOrigDest: Searching for Orig: ${start}, Dest: ${end}`
|
||||||
);
|
);
|
||||||
@ -31,7 +31,7 @@ async function findPisByOrigDest(start, end) {
|
|||||||
return await search;
|
return await search;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function findPisByCode(code) {
|
async function findPisByCode(code: string) {
|
||||||
logger.debug(`pisServices.findPisByCode: Searching for PIS code: ${code}`);
|
logger.debug(`pisServices.findPisByCode: Searching for PIS code: ${code}`);
|
||||||
const cleanCode = clean.removeNonNumeric(code);
|
const cleanCode = clean.removeNonNumeric(code);
|
||||||
const query = {
|
const query = {
|
||||||
@ -41,14 +41,27 @@ async function findPisByCode(code) {
|
|||||||
return await search;
|
return await search;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function findByTiplocArray(tiplocArray) {
|
async function findByTiplocArray(tiplocArray: string[]) {
|
||||||
const query = {
|
const query = {
|
||||||
tiplocs: tiplocArray,
|
tiplocs: tiplocArray,
|
||||||
};
|
};
|
||||||
const res = db.query("pis", query);
|
const res = await db.query("pis", query);
|
||||||
|
// If res is empty then try to find partial match
|
||||||
|
/* if (res.length) {
|
||||||
|
return res;
|
||||||
|
} else {
|
||||||
|
let partial = await findPartialMatchByTiploc(tiplocArray);
|
||||||
|
return partial
|
||||||
|
} */
|
||||||
return await res;
|
return await res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function findPartialMatchByTiploc(tiplocArray: string[]) {
|
||||||
|
// Do some magic here, similar to findPisByOrigDest but
|
||||||
|
// ensuring that the stops in the array match the last
|
||||||
|
// x number of items in the array.
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
supported,
|
supported,
|
||||||
findPisByOrigDest,
|
findPisByOrigDest,
|
Loading…
Reference in New Issue
Block a user