           0 
           records))
 
+;;; get line increments
+(defn get-increment-lines
+  [records]
+  (reduce #(+ %1 (- (:added-lines %2) (:deleted-lines %2))) 
+          0 
+          records))
+
+
 (defrecord date-lines-record
   [date lines])
 ;;;
 ;;; merge records by date
 ;;;
 (defn merge-records-by-date
-  [records]
+  [records functor]
   (let [dm (group-by get-date (filter (partial is-commit-in-date? "*") 
                                       (filter is-valid-record? records)))]
     (map #(->date-lines-record
              %1 
-             (get-modified-lines (get dm %1))) 
+             (functor (get dm %1))) 
          (keys dm))))
 
 ;;;

                                (:lines rs)))))

(defn write-workspace-dlr-to-csv
  [workspace file]
  (write-date-lines-record-to-csv
    (merge-records-by-date
      (get-workspace-records workspace))
    file))



;;; project's everyday progress

  {:project (:project record) :date (get-date record)})
  
(defn get-project-lines-records
  [workspace functor]
  (let [dm (group-by get-project-and-date  
            (filter is-valid-record? (get-workspace-records workspace)))]
    (map #(->project-lines-record
           (:project %1)
           (:date %1)
           (functor (get dm %1)))
         (keys dm))))
;;;
;;; project - loc
;;;
(defn write-workspace-plr-to-csv
  [workspace file functor]
  (with-open [*out* (java.io.FileWriter. file)]
    (doseq [rs (get-project-lines-records workspace functor)]
      (clojure.pprint/cl-format *out* 
                                "~s,~s,\"~d\"\r\n" 
                                (:project rs)
                                (:date rs)
                                (:lines rs)))))

(defn write-workspace-modified-lines-to-csv
  [workspace file ]
  (write-workspace-plr-to-csv workspace file get-modified-lines))

(defn write-workspace-increment-lines-to-csv
  [workspace file]
  (write-workspace-plr-to-csv workspace file get-increment-lines))

;;;
;;; count total line of project
;;;

