packages feed

hackage-sparks 0.5 → 0.5.1

raw patch · 2 files changed

+34/−26 lines, 2 filesdep +bytestringdep +downloaddep ~base

Dependencies added: bytestring, download

Dependency ranges changed: base

Files

Main.hs view
@@ -1,11 +1,11 @@ -------------------------------------------------------------------- -- | -- Module    : Generate sparkline graphs of hackage uploads--- Copyright : (c) Don Stewart 2008-9+-- Copyright : (c) Don Stewart 2008-2011 -- License   : BSD3 ----- Maintainer: Don Stewart <dons@galois.com>--- Stability : provisional+-- Maintainer: Don Stewart <dons00@gmail.com>+-- Stability : stable -- Portability: -- --------------------------------------------------------------------@@ -18,7 +18,8 @@ import System.Locale import System.Time import System.Time.Parse-import Text.HTML.Download+import Network.Download+import qualified Data.ByteString.Char8 as C  url = "http://hackage.haskell.org/packages/archive/log" @@ -31,29 +32,35 @@ main :: IO () main = do     pwd <- getCurrentDirectory-    src <- openURL url+    e   <- openURI url+    case e of+        Left  err  -> error $ "Failed to download: " ++ show err+        Right bsrc -> do { -    let dates = catMaybes . sort . map parse . lines $ src+    ; let src = C.unpack bsrc -    let today     = last dates-        permonth  = groupBy month dates-        thismonth = groupBy day . filter (month today) $ dates-        monthlies = map genericLength permonth-        dailies   = map genericLength thismonth-        alls      = reverse. take 90 . reverse $ map genericLength (groupBy (\a b -> month a b && day a b) dates)-        top       = maximum monthlies+    ; let dates = catMaybes . sort . map parse . lines $ src -    graph1 <- make (graph { limits = (0,round top) })  monthlies-    graph2 <- make (graph { limits = (0,20) }) dailies-    graph3 <- make (graph { limits = (0,20) }) alls+    ; let today     = last dates+          permonth  = groupBy month dates+          thismonth = groupBy day . filter (month today) $ dates+          monthlies = map genericLength permonth+          dailies   = map genericLength thismonth+          alls      = reverse. take 90 . reverse $ map genericLength (groupBy (\a b -> month a b && day a b) dates)+          top       = maximum monthlies -    savePngFile png1 graph1-    savePngFile png2 graph2-    savePngFile png3 graph3+    ; graph1 <- make (graph { limits = (0,round top) })  monthlies+    ; graph2 <- make (graph { limits = (0,20) }) dailies+    ; graph3 <- make (graph { limits = (0,20) }) alls -    putStrLn $ "Wrote: " ++ pwd </> png1-    putStrLn $ "Wrote: " ++ pwd </> png2-    putStrLn $ "Wrote: " ++ pwd </> png3+    ; savePngFile png1 graph1+    ; savePngFile png2 graph2+    ; savePngFile png3 graph3++    ; putStrLn $ "Wrote: " ++ pwd </> png1+    ; putStrLn $ "Wrote: " ++ pwd </> png2+    ; putStrLn $ "Wrote: " ++ pwd </> png3+    }    where     parse = parseCalendarTime defaultTimeLocale "%c"
hackage-sparks.cabal view
@@ -1,10 +1,11 @@ name:                hackage-sparks-version:             0.5+version:             0.5.1 homepage:            http://code.haskell.org/~dons/code/hackage-sparks license:             BSD3 license-file:        LICENSE author:              Don Stewart-maintainer:          dons@galois.com+copyright:           Don Stewart (c) 2008-2011+maintainer:          dons00@gmail.com category:            Distribution synopsis:            Generate sparkline graphs of hackage statistics description:         Generate sparkline graphs of hackage statistics@@ -17,8 +18,8 @@ executable hackagesparks     main-is:         Main.hs     if flag(small_base) -        build-depends:   base >= 3, old-locale, old-time, directory+        build-depends:   base >= 3 && < 5, old-locale, old-time, directory     else         build-depends:   base <  3-    build-depends:   hsparklines, tagsoup, parsedate, filepath+    build-depends:   hsparklines, tagsoup, parsedate, filepath, download, bytestring