From 239ff24c95458fdff0706b99b8dab9d2fc8c8386 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Sun, 2 Aug 2020 19:50:28 +0100 Subject: Use ORDER BY to sort the response for GET /trips SQL is quite useful. --- src/Trips.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Trips.hs') diff --git a/src/Trips.hs b/src/Trips.hs index 022631219c62..f90740363c52 100644 --- a/src/Trips.hs +++ b/src/Trips.hs @@ -33,10 +33,10 @@ delete dbFile tripKey = -- | Return a list of all of the trips in `dbFile`. listAll :: FilePath -> IO [T.Trip] listAll dbFile = withConnection dbFile $ \conn -> - query_ conn "SELECT username,destination,startDate,endDate,comment FROM Trips" + query_ conn "SELECT username,destination,startDate,endDate,comment FROM Trips ORDER BY date(startDate) ASC" -- | Return a list of all of the trips in `dbFile`. list :: FilePath -> T.Username -> IO [T.Trip] list dbFile username = withConnection dbFile $ \conn -> - query conn "SELECT username,destination,startDate,endDate,comment FROM Trips WHERE username = ?" + query conn "SELECT username,destination,startDate,endDate,comment FROM Trips WHERE username = ? ORDER BY date(startDate) ASC" (Only username) -- cgit 1.4.1