4.1.3
This commit is contained in:
@@ -55,6 +55,43 @@ function matchesCriteria (user, criteria = {}) {
|
||||
if (!user.job || !user.job.toLowerCase().includes(criteria.job.toLowerCase())) return false
|
||||
}
|
||||
|
||||
// Multi-select dating-profile fields: match if the candidate's stored
|
||||
// array overlaps ANY of the alert's selected values — mirrors the $in
|
||||
// semantics of criteriaToMongoFilter in partnerSearchController.js.
|
||||
if (criteria.relationship_goal?.length) {
|
||||
const userValues = user.relationship_goal || []
|
||||
if (!criteria.relationship_goal.some((v) => userValues.includes(v))) return false
|
||||
}
|
||||
if (criteria.personality_traits?.length) {
|
||||
const userValues = user.personality_traits || []
|
||||
if (!criteria.personality_traits.some((v) => userValues.includes(v))) return false
|
||||
}
|
||||
if (criteria.lifestyle?.length) {
|
||||
const userValues = user.lifestyle || []
|
||||
if (!criteria.lifestyle.some((v) => userValues.includes(v))) return false
|
||||
}
|
||||
if (criteria.interests?.length) {
|
||||
const userValues = user.interests || []
|
||||
if (!criteria.interests.some((v) => userValues.includes(v))) return false
|
||||
}
|
||||
if (criteria.values?.length) {
|
||||
const userValues = user.values || []
|
||||
if (!criteria.values.some((v) => userValues.includes(v))) return false
|
||||
}
|
||||
|
||||
// Single-select dating-profile fields: exact match.
|
||||
if (criteria.seeking_gender && user.seeking_gender !== criteria.seeking_gender) return false
|
||||
if (criteria.relationship_view && user.relationship_view !== criteria.relationship_view) return false
|
||||
if (criteria.geo_preference && user.geo_preference !== criteria.geo_preference) return false
|
||||
if (criteria.smoking_status && user.smoking_status !== criteria.smoking_status) return false
|
||||
|
||||
// children_status is multi-select (a user may pick more than one status) —
|
||||
// same overlap semantics as the multi-select fields above.
|
||||
if (criteria.children_status?.length) {
|
||||
const userValues = user.children_status || []
|
||||
if (!criteria.children_status.some((v) => userValues.includes(v))) return false
|
||||
}
|
||||
|
||||
if (criteria.country_id && user.country?.id !== criteria.country_id) return false
|
||||
if (criteria.province_id && user.province?.id !== criteria.province_id) return false
|
||||
if (criteria.city_id && user.city?.id !== criteria.city_id) return false
|
||||
@@ -67,8 +104,11 @@ function matchesCriteria (user, criteria = {}) {
|
||||
const MATCH_RELEVANT_FIELDS = [
|
||||
'gender', 'height', 'weight', 'size', 'birthday', 'hair_color', 'eye_color',
|
||||
'marital_status', 'residence_type', 'residence_area', 'vehicle_type',
|
||||
'vehicle_details', 'personal_style', 'job', 'income_range', 'moral_traits',
|
||||
'country', 'province', 'city', 'is_Register'
|
||||
'vehicle_details', 'personal_style', 'job', 'income_range',
|
||||
'country', 'province', 'city', 'is_Register',
|
||||
'relationship_goal', 'seeking_gender', 'desired_age_range', 'personality_traits',
|
||||
'lifestyle', 'interests', 'values', 'relationship_view', 'geo_preference',
|
||||
'children_status', 'smoking_status'
|
||||
]
|
||||
|
||||
function shouldCheck (user) {
|
||||
|
||||
Reference in New Issue
Block a user