This commit is contained in:
leca 2024-08-17 13:20:28 +03:00
parent 01a74e5c5e
commit c9ca11d412
1 changed files with 4 additions and 4 deletions

View File

@ -128,15 +128,15 @@ export class User {
AND NOT EXISTS(SELECT sender, recipient FROM read_profiles WHERE sender = $2 AND recipient = room_id)
AND ${myinterest !== 'b' ? "sex = $3" : "$3 = $3 AND $4 = $4 AND $5 = $5 AND $6 = $6 AND $7 = $7"}
AND ${myrange !== 0 ?
`location = ANY(ARRAY(SELECT ID
`(location = ANY(ARRAY(SELECT ID
FROM cities
WHERE
check_distance($6::double precision, $7::double precision, lat, lng, $5::double precision)
AND (check_distance($6::double precision, $7::double precision, lat, lng, range) OR range = 0)
))`
)))`
:
`range = 0 OR
check_distance($6::double precision, $7::double precision, (SELECT lat FROM cities WHERE ID = location), (SELECT lng FROM cities WHERE ID = location), range)`
`(range = 0 OR
check_distance($6::double precision, $7::double precision, (SELECT lat FROM cities WHERE ID = location), (SELECT lng FROM cities WHERE ID = location), range))`
}
AND (interest = $4 OR interest = 'b')
ORDER BY RANDOM()