@@ -123,7 +123,8 @@ object PhotoprismSlideshowApp extends cask.MainRoutes{
123
123
def randomPhoto (categories : String ) = {
124
124
125
125
// Ugly hack for IN condition
126
- val categoriesList = categories.split(" ," ).map(_.trim).filter(_.nonEmpty).toList
126
+ val categoriesList = categories.split(" ," ).map(_.trim).filter(_.nonEmpty).toList
127
+ val input = (0 to 6 ).map(i => categoriesList.lift(i).getOrElse(" TO_BE_IGNORED" ))
127
128
128
129
ds.run:
129
130
val photo = (sql """
@@ -133,9 +134,9 @@ object PhotoprismSlideshowApp extends cask.MainRoutes{
133
134
INNER JOIN photos_albums pa ON pa.photo_uid = p.photo_uid
134
135
INNER JOIN albums a ON a.album_uid = pa.album_uid
135
136
WHERE a.album_type = 'album'
136
- AND a.album_category IN ( ${categoriesList.mkString( " ' " , " ',' " , " ' " )} )
137
+ AND a.album_category IN ( ${input( 0 )} , ${input( 1 )} , ${input( 2 )} , ${input( 3 )} , ${input( 4 )} , ${input( 5 )} , ${input( 6 )} )
137
138
AND p.photo_type = 'image'
138
- ORDER BY ${sqlRandomFunction} LIMIT 1 """ .read[Photo ]).headOption.getOrElse(Photo (" INVALID_PHOTO" ," INVALID PHOTO" ," " ," " ," " ))
139
+ ORDER BY RAND() LIMIT 1 """ .read[Photo ]).headOption.getOrElse(Photo (" INVALID_PHOTO" ," INVALID PHOTO" ," " ," " ," " ))
139
140
cask.Response (
140
141
s """
141
142
{
@@ -153,6 +154,7 @@ object PhotoprismSlideshowApp extends cask.MainRoutes{
153
154
154
155
// Ugly hack for IN condition
155
156
val categoriesList = categories.split(" ," ).map(_.trim).filter(_.nonEmpty).toList
157
+ val input = (0 to 6 ).map(i => categoriesList.lift(i).getOrElse(" TO_BE_IGNORED" ))
156
158
157
159
ds.run:
158
160
val photo = (sql """
@@ -162,9 +164,9 @@ object PhotoprismSlideshowApp extends cask.MainRoutes{
162
164
INNER JOIN photos_albums pa ON pa.photo_uid = p.photo_uid
163
165
INNER JOIN albums a ON a.album_uid = pa.album_uid
164
166
WHERE a.album_type = 'album'
165
- AND a.album_category IN ( ${categoriesList.mkString( " ' " , " ',' " , " ' " )} )
167
+ AND a.album_category IN ( ${input( 0 )} , ${input( 1 )} , ${input( 2 )} , ${input( 3 )} , ${input( 4 )} , ${input( 5 )} , ${input( 6 )} )
166
168
AND p.photo_type = 'image'
167
- ORDER BY ${sqlRandomFunction} LIMIT 1 """ .read[Photo ]).headOption.getOrElse(Photo (" INVALID_PHOTO" ," INVALID PHOTO" ," " ," " ," " ))
169
+ ORDER BY RAND() LIMIT 1 """ .read[Photo ]).headOption.getOrElse(Photo (" INVALID_PHOTO" ," INVALID PHOTO" ," " ," " ," " ))
168
170
cask.Response (
169
171
doctype(" html" )(
170
172
html(
0 commit comments