 (require '[arachnida.config        :as config])
 (require '[arachnida.db-interface  :as db-interface])
 (require '[arachnida.html-renderer :as html-renderer])
+
+(defn start-of-year
+    [year]
+    (str year "-01-01"))
+
+(defn end-of-year
+    [year]
+    (str year "-12-31"))
+
+(defn read-stat-for-product
+    [product-id start-year end-year]
+    (into (sorted-map)
+        (for [year (range start-year (inc end-year))]
+            [year (db-interface/read-statistic-for-product product-id (start-of-year year) (end-of-year year))])))
+
+(defn read-stat-for-product-repo
+    [product-id start-year end-year]
+    (into (sorted-map)
+        (for [year (range start-year (inc end-year))]
+            [year (db-interface/read-statistic-for-product-repo product-id (start-of-year year) (end-of-year year))])))
+
+(defn read-stat-for-product-and-repo
+    [product-id repository-name start-year end-year]
+    (into (sorted-map)
+        (for [year (range start-year (inc end-year))]
+            [year (db-interface/read-statistic-for-product-and-repo product-id repository-name (start-of-year year) (end-of-year year))])))
+
+(defn get-year-data
+    [stat what]
+    (for [s stat]
+        [(key s) (or (get (val s) what) 0)]))
 
 (defn read-stat-per-weeks
     [first-day last-day]

          ;product-repo (read-stat-for-product-repo product-id @config/start-year @config/end-year)]
        (-> (html-renderer/render-product-page product-name repositories product-stat @config/mailto year-graph-data-1 year-graph-data-2)
            continue-processing)))

(defn get-year-data
    [stat what]
    (for [s stat]
        [(key s) (or (get (val s) what) 0)]))

(defn perform-repository-page
    [request]

        (-> (html-renderer/render-author-week-repo-page author-name selected-week stat-for-week product repo @config/mailto)
            continue-processing)))

(defn perform-product-page
    [request]
    (let [params (:params request)
