ddstats/sql/maps/search_maps.sql

9 lines
665 B
MySQL
Raw Normal View History

2023-04-16 20:55:28 +02:00
SELECT record_maps.map, category, points, stars, mappers, release, width, height, tiles
FROM record_maps JOIN record_mapinfo_array ON record_maps.map = record_mapinfo_array.map
WHERE ($1::TEXT IS NULL OR record_maps.map ILIKE $1)
AND (COALESCE(ARRAY_LENGTH($2::TEXT[], 1), NULL)::BOOLEAN IS TRUE OR $2::TEXT[] <@ mappers::TEXT[])
AND ($3::TEXT IS NULL OR category = $3)
AND ($4::SMALLINT[] IS NULL OR stars = ANY($4))
AND ($5::TIMESTAMP IS NULL OR release >= $5)
AND ($6::TIMESTAMP IS NULL OR release <= $6)
AND (COALESCE(ARRAY_LENGTH($7::TEXT[], 1), NULL)::BOOLEAN IS TRUE OR $7::TEXT[] <@ tiles::TEXT[])