about summary refs log tree commit diff
path: root/src/Trips.hs
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-08-02T18·50+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-08-02T18·50+0100
commit239ff24c95458fdff0706b99b8dab9d2fc8c8386 (patch)
tree7eeb12038122874b00247bf3a7dfabb18ff90348 /src/Trips.hs
parent0cb9642a8acdd7d6a7a63eba3ccd98d0238a0bcb (diff)
Use ORDER BY to sort the response for GET /trips
SQL is quite useful.
Diffstat (limited to 'src/Trips.hs')
-rw-r--r--src/Trips.hs4
1 files changed, 2 insertions, 2 deletions
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)