aboutsummaryrefslogtreecommitdiff
path: root/hoarder-server/src/Hoarder/Server/Handler/Movie.hs
diff options
context:
space:
mode:
Diffstat (limited to 'hoarder-server/src/Hoarder/Server/Handler/Movie.hs')
-rw-r--r--hoarder-server/src/Hoarder/Server/Handler/Movie.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/hoarder-server/src/Hoarder/Server/Handler/Movie.hs b/hoarder-server/src/Hoarder/Server/Handler/Movie.hs
index 7d9e610..84ae2d5 100644
--- a/hoarder-server/src/Hoarder/Server/Handler/Movie.hs
+++ b/hoarder-server/src/Hoarder/Server/Handler/Movie.hs
@@ -108,10 +108,15 @@ searchToSql ms =
E.orderBy $ searchSortBysToSql m (ms ^. movieSearchSortBys)
return (m, maybei)
+filterFst :: Eq a => [(a, b)] -> [(a, b)]
+filterFst [] = []
+filterFst (x1 : []) = [x1]
+filterFst (x1 : x2 : xs) = if (fst x1 == fst x2) then filterFst (x2 : xs) else x1 : (filterFst (x2 : xs))
+
getResponseMovies :: MovieSearch -> App [ResponseSimpleMovie]
getResponseMovies ms = do
movies <- runDB (searchToSql ms)
- return $ map getresponsemovieaux movies
+ return $ map getresponsemovieaux (filterFst movies)
where
getresponsemovieaux (Entity mid m, mei) = ResponseSimpleMovie
(fromSqlKey mid)