about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <viam@humac.com>2012-03-03T03·02+0100
committerVincent Ambo <viam@humac.com>2012-03-03T03·02+0100
commit7114876693cf5b2ce9ac4b7d7c5121aba4be94e2 (patch)
treedec26763f79629d3000adf2e798e4fc54198e77e
parent65a5443e2d3f523dc3a61e6cdf2a9a588e6ac368 (diff)
* limiting amount of queries with couchDB's limit parameter
-rw-r--r--src/Blog.hs6
-rw-r--r--src/Main.hs6
2 files changed, 6 insertions, 6 deletions
diff --git a/src/Blog.hs b/src/Blog.hs
index 61c8bc3f029d..0709dd3a3b2a 100644
--- a/src/Blog.hs
+++ b/src/Blog.hs
@@ -72,12 +72,12 @@ blogTemplate lang t_append body = H.docTypeHtml $ do --add body
             H.a ! A.href (toValue imu) ! A.target "_blank" $ "iMessage"
             "."
 
-renderEntries :: [Entry] -> Int -> String-> Html
-renderEntries entries num topText = H.div ! A.class_ "innerBox" $ do
+renderEntries :: [Entry] -> String-> Html
+renderEntries entries topText = H.div ! A.class_ "innerBox" $ do
     H.div ! A.class_ "innerBoxTop" $ toHtml topText
     H.div ! A.class_ "innerBoxMiddle" $ do
         H.ul $ 
-            sequence_ $ take num $ reverse $ map showEntry entries
+            sequence_ $ reverse $ map showEntry entries
     where
         showEntry :: Entry -> Html
         showEntry e = H.li $ do 
diff --git a/src/Main.hs b/src/Main.hs
index 3c4537597611..60da9946461d 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -64,14 +64,14 @@ tryEntry (Just entry) = toResponse $ blogTemplate eLang eTitle $ renderEntry ent
 
 showIndex :: BlogLang -> ServerPart Response
 showIndex lang = do
-    entries <- getLatest lang []
-    ok $ toResponse $ blogTemplate lang "" $ renderEntries entries 6 (topText lang)
+    entries <- getLatest lang [("limit", toJSON (6 :: Int)), ("descending", toJSON True)]
+    ok $ toResponse $ blogTemplate lang "" $ renderEntries entries (topText lang)
 
 showMonth :: Int -> Int -> BlogLang -> ServerPart Response
 showMonth y m lang = do
     entries <- getLatest lang $ makeQuery startkey endkey
     ok $ toResponse $ blogTemplate lang month 
-        $ renderEntries entries (length entries) month
+        $ renderEntries entries month
   where
     month = getMonth lang y  m
     startkey = JSArray [toJSON y, toJSON m]