eslint fixes

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-04-30 22:01:45 +01:00
parent 080a235c2b
commit c0c50d0e5b

View File

@ -5,25 +5,25 @@ const log = require('../utils/log.utils')
const clean = require('../utils/sanitizer.utils') const clean = require('../utils/sanitizer.utils')
async function findPisByOrigDest(start,end) { async function findPisByOrigDest(start,end) {
log.out(`pisServices.findPisByOrigDest: Searching for PIS for Orig: ${start}, Dest: ${end}`, "dbug") log.out(`pisServices.findPisByOrigDest: Searching for PIS for Orig: ${start}, Dest: ${end}`, 'dbug')
const firstCrs = clean.cleanApiEndpointTxt(start.toLowerCase()) const firstCrs = clean.cleanApiEndpointTxt(start.toLowerCase())
const lastCrs = clean.cleanApiEndpointTxt(end.toLowerCase()) const lastCrs = clean.cleanApiEndpointTxt(end.toLowerCase())
const query = { const query = {
stops: { stops: {
$all: [ $all: [
{ $elemMatch: { $eq: firstCrs } }, { $elemMatch: { $eq: firstCrs } },
{ $elemMatch: { $eq: lastCrs } } { $elemMatch: { $eq: lastCrs } }
] ]
}, },
$expr: { $expr: {
$and: [ $and: [
{ $eq: [{ $arrayElemAt: [ "$stops", -1 ] }, lastCrs] }, { $eq: [{ $arrayElemAt: [ '$stops', -1 ] }, lastCrs] },
{ $eq: [{ $arrayElemAt: [ "$stops", 0 ] }, firstCrs] } { $eq: [{ $arrayElemAt: [ '$stops', 0 ] }, firstCrs] }
] ]
} }
} }
//const oldQuery = {$and:[{$expr:{$eq:[{$first:"$stops"},firstCrs]}},{$expr:{$eq:[{$last:"$stops"},lastCrs]}}]} //const oldQuery = {$and:[{$expr:{$eq:[{$first:"$stops"},firstCrs]}},{$expr:{$eq:[{$last:"$stops"},lastCrs]}}]}
const search = db.query("pis", query) const search = db.query('pis', query)
return search return search
} }