hackage-plot 0.2 → 0.2.1
raw patch · 2 files changed
+30/−13 lines, 2 filesdep +bytestringdep +download-curldep −tagsoupdep ~base
Dependencies added: bytestring, download-curl
Dependencies removed: tagsoup
Dependency ranges changed: base
Files
- Main.hs +26/−9
- hackage-plot.cabal +4/−4
Main.hs view
@@ -1,10 +1,11 @@+{-# LANGUAGE ScopedTypeVariables #-} -------------------------------------------------------------------- -- | -- Module : Generate gnuplot graphs of hackage activity--- Copyright : (c) Don Stewart 2008+-- Copyright : (c) Don Stewart 2008-2013 -- License : BSD3 ----- Maintainer: Don Stewart <dons@galois.com>+-- Maintainer: Don Stewart <dons00@gmail.com> -- Stability : provisional -- Portability: --@@ -17,9 +18,12 @@ import System.Locale import System.Time import System.Time.Parse-import Text.HTML.Download+-- import Text.HTML.Download import Graphics.Gnuplot.Simple import qualified Data.IntMap as I+import Text.Printf+import Network.Curl.Download+import Data.ByteString.Char8 (unpack) url = "http://hackage.haskell.org/packages/archive/log" @@ -28,18 +32,27 @@ let ys = [ (i,d) | ((_,d), i) <- zip xs [1..] ] zs = sliding ys [1.. length ys] + writeFile "/tmp/data1"+ (unlines . map (\((x,y) :: (Int,Int)) -> printf "%d %d" x y ) $ ys)+ writeFile "/tmp/data2"+ (unlines . map (\((x,y) :: (Int,Double)) -> printf "%d %f" x y) $ zs)+ plotList [Key Nothing ,YRange (0,maximum (map snd zs) + 1) ,XLabel "Days since launch of Hackage"- ,YLabel "Unique uploads"- ,Title "Daily uploads (90 day moving average) to http://hackage.haskell.org"- ,PNG "/tmp/hackage-daily-graph.png"] (map snd zs)+ ,YLabel "Unique uploads each day"+ ,Title "Daily uploads (180 day moving average) to http://hackage.haskell.org"+ -- ,SVG "/tmp/hackage-daily-graph.svg"+ ,Custom "grid" []+ ,Custom "terminal svg;set output \"/tmp/hackage-daily-graph.svg\""[]+ ,Custom "style line" ["3","lc","3","lw","3"]+ ] (map snd zs) - print "Output written to: /tmp/hackage-daily-graph.png"+ print "Output written to: /tmp/hackage-daily-graph.svg" -- sliding average window window :: Int-window = 90+window = 180 -- -- compute the 7-day sliding average, starting with a sparse sequence@@ -60,7 +73,11 @@ gettime :: IO [(CalendarTime, Int)] gettime = do pwd <- getCurrentDirectory- src <- openURL url+-- src <- openURL url+ e <- openURI url+ let src = case e of+ Left err -> error err+ Right s -> unpack s let dates = catMaybes . sort . map parse . lines $ src
hackage-plot.cabal view
@@ -1,10 +1,10 @@ name: hackage-plot-version: 0.2+version: 0.2.1 homepage: http://code.haskell.org/~dons/code/hackage-plot license: BSD3 license-file: LICENSE author: Don Stewart-maintainer: dons@galois.com+maintainer: dons00@gmail.com category: Distribution synopsis: Generate cumulative graphs of hackage uploads description: Generate cumulative graphs of hackage uploads@@ -17,8 +17,8 @@ executable hackage-plot main-is: Main.hs if flag(small_base) - build-depends: base >= 3, old-locale, old-time, directory, containers+ build-depends: base >= 3 && < 5, old-locale, old-time, directory, containers, bytestring else build-depends: base < 3- build-depends: gnuplot > 0.2, tagsoup, parsedate, filepath+ build-depends: gnuplot > 0.2, download-curl, parsedate, filepath