From 8f709d197e6fb8788a9529f99ea75acaa3ce5cf5 Mon Sep 17 00:00:00 2001 From: Flummi Date: Sat, 26 May 2018 15:39:03 +0200 Subject: [PATCH] fix random, fml --- src/websrv.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/websrv.js b/src/websrv.js index b159b62..c7903e1 100644 --- a/src/websrv.js +++ b/src/websrv.js @@ -312,15 +312,15 @@ function Websrv(tlib) { switch(url[3]) { case "image": mimes = ["image/png", "image/gif", "image/jpeg"]; - query = "where ("+mimes.map(mime => "`mime` = '"+mime+"'").join(" or ")+") and rand() limit 1"; + query = "where "+mimes.map(mime => "`mime` = '"+mime+"'").join(" or ")+" order by rand() limit 1"; break; case "video": mimes = ["video/webm", "video/mp4", "video/quicktime"]; - query = "where ("+mimes.map(mime => "`mime` = '"+mime+"'").join(" or ")+") and rand() limit 1"; + query = "where "+mimes.map(mime => "`mime` = '"+mime+"'").join(" or ")+" order by rand() limit 1"; break; case "audio": mimes = ["audio/mpeg", "audio/flac", "audio/x-flac", "audio/ogg"]; - query = "where ("+mimes.map(mime => "`mime` = '"+mime+"'").join(" or ")+") and rand() limit 1"; + query = "where "+mimes.map(mime => "`mime` = '"+mime+"'").join(" or ")+" order by rand() limit 1"; break; default: query = "order by rand() limit 1";