hackage-plot (empty) → 0.2
raw patch · 6 files changed
+131/−0 lines, 6 filesdep +basedep +containersdep +directorysetup-changedbinary-added
Dependencies added: base, containers, directory, filepath, gnuplot, old-locale, old-time, parsedate, tagsoup
Files
- LICENSE +30/−0
- Main.hs +74/−0
- Setup.lhs +3/−0
- examples/hackage-daily.png binary
- examples/hackage-monthly.png binary
- hackage-plot.cabal +24/−0
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2008 Don Stewart++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions+are met:++1. Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright+ notice, this list of conditions and the following disclaimer in the+ documentation and/or other materials provided with the distribution.++3. Neither the name of the author nor the names of his contributors+ may be used to endorse or promote products derived from this software+ without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE+POSSIBILITY OF SUCH DAMAGE.
+ Main.hs view
@@ -0,0 +1,74 @@+--------------------------------------------------------------------+-- |+-- Module : Generate gnuplot graphs of hackage activity+-- Copyright : (c) Don Stewart 2008+-- License : BSD3+--+-- Maintainer: Don Stewart <dons@galois.com>+-- Stability : provisional+-- Portability:+--+--------------------------------------------------------------------++import Data.List+import Data.Maybe+import System.Directory+import System.FilePath+import System.Locale+import System.Time+import System.Time.Parse+import Text.HTML.Download+import Graphics.Gnuplot.Simple+import qualified Data.IntMap as I++url = "http://hackage.haskell.org/packages/archive/log"++main = do+ xs <- gettime+ let ys = [ (i,d) | ((_,d), i) <- zip xs [1..] ]+ zs = sliding ys [1.. length ys]++ 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)++ print "Output written to: /tmp/hackage-daily-graph.png"++-- sliding average window+window :: Int+window = 90++--+-- compute the 7-day sliding average, starting with a sparse sequence+--+-- sliding :: [(Int,Int)] -> [Int] -> [(Int,Double)]+sliding [] _ = []+sliding xs days = [ (i,slidingAv i) | i <- days' ]+ where+ m = window `div` 2 -- 1/2 n++ days' = drop m . take (max 0 (length days - window+m+1)) $ days+ table = I.fromList xs :: I.IntMap Int -- to handle missing elems easily++ slidingAv :: Int -> Double+ slidingAv i = fromIntegral (sum seqN) / fromIntegral window+ where seqN = map (\j -> I.findWithDefault 0 j table) [i-m..i+(window-m-1)]++gettime :: IO [(CalendarTime, Int)]+gettime = do+ pwd <- getCurrentDirectory+ src <- openURL url++ let dates = catMaybes . sort . map parse . lines $ src++ let days = groupBy day $ dates++ return [ (head d, length d) | d <- days ]++ where+ parse = parseCalendarTime defaultTimeLocale "%c"+ month a b = ctYear a == ctYear b && ctMonth a == ctMonth b+ day a b = month a b && ctDay a == ctDay b
+ Setup.lhs view
@@ -0,0 +1,3 @@+#!/usr/bin/env runhaskell+> import Distribution.Simple+> main = defaultMain
+ examples/hackage-daily.png view
binary file changed (absent → 191 bytes)
+ examples/hackage-monthly.png view
binary file changed (absent → 226 bytes)
+ hackage-plot.cabal view
@@ -0,0 +1,24 @@+name: hackage-plot+version: 0.2+homepage: http://code.haskell.org/~dons/code/hackage-plot+license: BSD3+license-file: LICENSE+author: Don Stewart+maintainer: dons@galois.com+category: Distribution+synopsis: Generate cumulative graphs of hackage uploads+description: Generate cumulative graphs of hackage uploads+cabal-version: >= 1.2+build-type: Simple++flag small_base+ description: Choose the new smaller, split-up base package.++executable hackage-plot+ main-is: Main.hs+ if flag(small_base) + build-depends: base >= 3, old-locale, old-time, directory, containers+ else+ build-depends: base < 3+ build-depends: gnuplot > 0.2, tagsoup, parsedate, filepath+