Commits

Miki Tebeka  committed 8b084ed

Logs per day

  • Participants
  • Parent commits f3a48e8

Comments (0)

Files changed (1)

File src/clj2010.clj

 (ns clj2010
   (:require [apricot-soup :as soup])
-  (:use [clj-time.core :only (date-time plus minutes year month day)]
+  (:use [clj-time.core :only (date-time plus minutes year month day-of-week)]
         [clj-time.coerce :only (to-long)]
         [clj-time.format :only (formatter unparse)]
         [incanter.core :only (save sum)]
 (defn month-only [time]
   (date-time (year time) (month time)))
 
-(defn day-only [time]
-  (date-time (year time) (month time) (day time)))
-
 (defn gen-chart [result job]
   (let [xs (sort (keys result))
         ys (map #(result %) xs)
   :max 100
   :outfile "thanked"})
 
+
+(def daylogs {
+  :map (fn [record] [[(day-of-week (:time record)) 1]])
+  ; Assume we have 52 of each week day per year
+  :reduce (fn [key values] (/ (sum values) 52.0))
+  :title "Lines/Day"
+  :x-label "Day"
+  :y-label "Lines (average)"
+  :outfile "daylogs"
+  :x-format (zipmap (range 1 8) ["Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun"])})
+
 (def *jobs* [
   numlines 
   numusers 
   active
   words 
   thanked
+  daylog
 ])
 
 (defn -main []