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