Search: don't filter by age for people who hide their age
This commit is contained in:
parent
eb571e1933
commit
c9c89100f9
|
@ -320,13 +320,29 @@ func SearchUsers(user *User, search *UserSearch, pager *Pagination) ([]*User, er
|
||||||
|
|
||||||
if search.AgeMin > 0 {
|
if search.AgeMin > 0 {
|
||||||
date := time.Now().AddDate(-search.AgeMin, 0, 0)
|
date := time.Now().AddDate(-search.AgeMin, 0, 0)
|
||||||
wheres = append(wheres, "birthdate <= ?")
|
wheres = append(wheres, `
|
||||||
|
birthdate <= ? AND NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM profile_fields
|
||||||
|
WHERE user_id = users.id
|
||||||
|
AND name = 'hide_age'
|
||||||
|
AND value = 'true'
|
||||||
|
)
|
||||||
|
`)
|
||||||
placeholders = append(placeholders, date)
|
placeholders = append(placeholders, date)
|
||||||
}
|
}
|
||||||
|
|
||||||
if search.AgeMax > 0 {
|
if search.AgeMax > 0 {
|
||||||
date := time.Now().AddDate(-search.AgeMax-1, 0, 0)
|
date := time.Now().AddDate(-search.AgeMax-1, 0, 0)
|
||||||
wheres = append(wheres, "birthdate >= ?")
|
wheres = append(wheres, `
|
||||||
|
birthdate >= ? AND NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM profile_fields
|
||||||
|
WHERE user_id = users.id
|
||||||
|
AND name = 'hide_age'
|
||||||
|
AND value = 'true'
|
||||||
|
)
|
||||||
|
`)
|
||||||
placeholders = append(placeholders, date)
|
placeholders = append(placeholders, date)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user