Capitalization of plate numbers in search
This commit is contained in:
parent
9f4ab0f1cd
commit
a3fc94e33f
@ -1,26 +1,26 @@
|
||||
class Utils {
|
||||
static makeVehiclesSearchQuery(queryParams, email) {
|
||||
const {
|
||||
query,
|
||||
brand,
|
||||
model,
|
||||
color,
|
||||
regions,
|
||||
fromDate,
|
||||
toDate,
|
||||
addedBy,
|
||||
fromDateUpdated,
|
||||
toDateUpdated,
|
||||
const {
|
||||
query,
|
||||
brand,
|
||||
model,
|
||||
color,
|
||||
regions,
|
||||
fromDate,
|
||||
toDate,
|
||||
addedBy,
|
||||
fromDateUpdated,
|
||||
toDateUpdated,
|
||||
fromLocationDate,
|
||||
toLocationDate,
|
||||
year,
|
||||
scope
|
||||
} = queryParams;
|
||||
|
||||
let numberQuery = Utils.makeNumberQuery(scope, query, regions?.split(',') ?? []);
|
||||
let findQuery = {
|
||||
'brand.name.normalized': brand,
|
||||
'model.name.normalized': model,
|
||||
|
||||
let numberQuery = Utils.makeNumberQuery(scope, query.toUpperCase(), regions?.split(',') ?? []);
|
||||
let findQuery = {
|
||||
'brand.name.normalized': brand,
|
||||
'model.name.normalized': model,
|
||||
color
|
||||
};
|
||||
|
||||
@ -71,11 +71,11 @@ class Utils {
|
||||
findQuery.addedBy = { $ne: email };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let findQueryFiltered = Object.fromEntries(Object.entries(findQuery).filter(([,val]) => val ));
|
||||
return { ...findQueryFiltered, ...numberQuery };
|
||||
}
|
||||
|
||||
|
||||
static makeNumberQuery(scope, number, regions) {
|
||||
|
||||
let mainQuery = { number: { $regex: number } };
|
||||
@ -113,7 +113,7 @@ class Utils {
|
||||
if(to) {
|
||||
conditions.push({ $lte: to });
|
||||
}
|
||||
|
||||
|
||||
return { $and: conditions };
|
||||
}
|
||||
|
||||
@ -148,4 +148,4 @@ class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
export default Utils;
|
||||
export default Utils;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user