@@ -28,7 +28,7 @@ async function findPisByOrigDest(start,end) {
|
||||
}
|
||||
|
||||
async function findPisByCode(code) {
|
||||
log.out(`pisServices.findPisByCode: Searching for PIS code: ${code}`);
|
||||
log.out(`pisServices.findPisByCode: Searching for PIS code: ${code}`, 'dbug');
|
||||
const cleanCode = clean.removeNonNumeric(code);
|
||||
const query = {
|
||||
'code': parseInt(cleanCode)
|
||||
@@ -37,9 +37,21 @@ async function findPisByCode(code) {
|
||||
return await search;
|
||||
}
|
||||
|
||||
async function findRandom() {
|
||||
log.out('pisServices.findRandom: Finding five random PIS Codes', 'dbug');
|
||||
const query = {
|
||||
$sample: {
|
||||
size: 5
|
||||
}
|
||||
};
|
||||
const results = db.query('pis', query);
|
||||
return results;
|
||||
}
|
||||
|
||||
// Hopefully at some point, I will also be able to implement a find PIS code by headcode option.
|
||||
|
||||
module.exports = {
|
||||
findPisByOrigDest,
|
||||
findPisByCode
|
||||
findPisByCode,
|
||||
findRandom
|
||||
};
|
||||
Reference in New Issue
Block a user