diff --git a/Main.hs b/Main.hs index 326dfd0b1..cf7596a82 100644 --- a/Main.hs +++ b/Main.hs @@ -91,8 +91,10 @@ respondWithRangedResult rr = responseLBS status206 [ json, ("Content-Range", - "0-" <> (BS.pack . show . rrTo) rr <> "/" - <> (BS.pack . show . rrTotal) rr) + (BS.pack . show . rrFrom ) rr <> "-" + <> (BS.pack . show . rrTo ) rr <> "/" + <> (BS.pack . show . rrTotal) rr + ) ] (rrBody rr) where diff --git a/PgQuery.hs b/PgQuery.hs index 7308e2e4d..9be82ff1f 100644 --- a/PgQuery.hs +++ b/PgQuery.hs @@ -41,9 +41,13 @@ getRows schema table qq range conn = do return $ case r of [[total, limited_total, json]] -> - RangedResult 0 (fromSql limited_total) (fromSql total) (fromSql json) + RangedResult offset (offset + fromSql limited_total - 1) + (fromSql total) (fromSql json) _ -> RangedResult 0 0 0 "" + where + offset = fromMaybe 0 $ R.offset <$> range + whereClause :: Net.Query -> QuotedSql whereClause qs = if null qs then ("", []) else (" where ", []) <> conjunction