Added country and birthday filters to actors page.
This commit is contained in:
@@ -106,13 +106,17 @@ function buildQuery(filters) {
|
||||
});
|
||||
}
|
||||
|
||||
if (filters.gender) {
|
||||
query.bool.must.push({
|
||||
equals: {
|
||||
gender: filters.gender,
|
||||
},
|
||||
});
|
||||
}
|
||||
['gender', 'country'].forEach((attribute) => {
|
||||
if (filters[attribute]) {
|
||||
console.log(attribute, filters[attribute]);
|
||||
|
||||
query.bool.must.push({
|
||||
equals: {
|
||||
[attribute]: filters[attribute],
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
['age', 'height', 'weight'].forEach((attribute) => {
|
||||
if (filters[attribute]) {
|
||||
@@ -127,6 +131,39 @@ function buildQuery(filters) {
|
||||
}
|
||||
});
|
||||
|
||||
if (filters.dateOfBirth && filters.dobType === 'dateOfBirth') {
|
||||
query.bool.must.push({
|
||||
equals: {
|
||||
date_of_birth: Math.floor(filters.dateOfBirth.getTime() / 1000),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (filters.dateOfBirth && filters.dobType === 'birthday') {
|
||||
expressions.month_of_birth = 'month(date_of_birth)';
|
||||
expressions.day_of_birth = 'day(date_of_birth)';
|
||||
|
||||
const month = filters.dateOfBirth.getMonth() + 1;
|
||||
const day = filters.dateOfBirth.getDate();
|
||||
|
||||
query.bool.must.push({
|
||||
bool: {
|
||||
must: [
|
||||
{
|
||||
equals: {
|
||||
month_of_birth: month,
|
||||
},
|
||||
},
|
||||
{
|
||||
equals: {
|
||||
day_of_birth: day,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (filters.cup) {
|
||||
expressions.cup_in_range = `regex(cup, '^[${filters.cup[0]}-${filters.cup[1]}]')`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user