Permalink
Browse files

Add incrementStat

  • Loading branch information...
qxjit committed Mar 20, 2012
1 parent a9da34d commit 8d1b5c7631030ed9f3d1a02c794fa9a45c77baf4
Showing with 7 additions and 1 deletion.
  1. +1 −1 src/Site.hs
  2. +6 −0 src/Snap/Snaplet/Stats.hs
View
@@ -57,7 +57,7 @@ retrack = ifTop $ do
body <- (readRequestBody (1024*1042::Int64))
queueInBackground (B.concat (toChunks body))
- modifyStat "Posts Received" (Just . (maybe 1 (+1)))
+ incrementStat "Posts Received"
writeBS "Got it!\n"
@@ -7,6 +7,7 @@ module Snap.Snaplet.Stats
, statsInit
, initStatValue
, modifyStat
+ , incrementStat
) where
import Control.Concurrent
@@ -39,6 +40,11 @@ modifyStat statName f = with' statsLens $ do
Stats statsMap <- get
liftIO $ modifyMVar_ statsMap (return . Map.alter f statName)
+incrementStat :: HasStats a
+ => String
+ -> Handler a a ()
+incrementStat statName = modifyStat statName (Just . (maybe 1 (+1)))
+
initStatValue :: HasStats a
=> String
-> Integer

0 comments on commit 8d1b5c7

Please sign in to comment.