~pepe/neil

0f680640d4c4fbbdf4bd2b031073e1a23631907d — Josef Pospíšil 5 months ago aa575d0
Clean up stats
2 files changed, 19 insertions(+), 18 deletions(-)

M neil/watch/stats/init.janet
M neil/watch/stats/utils.janet
M neil/watch/stats/init.janet => neil/watch/stats/init.janet +18 -17
@@ 1,6 1,5 @@
(use chidi/response eleanor)
(use /neil/watch/utils /neil/watch/middleware)
(import /neil/watch/stats/utils)
(use /neil/watch/utils /neil/watch/middleware /neil/watch/stats/utils)

(defn index [brush trevor]
  (fn [{:params {:project-id pid}}]


@@ 9,35 8,37 @@
              :trevor trevor
              :stats true
              :content
              (page stats @{:project-select (projects-ts-sorted brush)
                            :project (and pid (load brush pid))
                            :worked-intervals (work-intervals-sums brush pid)})})))
              (page stats
                    @{:project-select (projects-ts-sorted brush)
                      :project (and pid (load brush pid))
                      :worked-intervals (work-intervals-sums brush pid)})})))

(defn interval [brush]
  (fn [{:params {:interval i :project project :state state}}]
    (def [projects clients] (retrieve brush [:clients (collect) (in-all :projects) merged]))
    (def [projects clients] (retrieve brush [:clients (collect)
                                             (in-all :projects) merged]))
    (def tdy (today))
    (capout
      (case i
        "today"
        (utils/loop-interval-tasks (:epoch tdy))
        (loop-interval-tasks (:epoch tdy))
        "yesterday"
        (utils/loop-interval-tasks (:epoch (yesterday)) (:epoch tdy))
        (loop-interval-tasks (:epoch (yesterday)) (:epoch tdy))
        "current-week"
        (utils/loop-interval-tasks (:epoch (current-week-start)))
        (loop-interval-tasks (:epoch (current-week-start)))
        "last-week"
        (utils/loop-interval-tasks (:epoch (last-week-start))
                                   (:epoch (current-week-start)))
        (loop-interval-tasks (:epoch (last-week-start))
                             (:epoch (current-week-start)))
        "current-month"
        (utils/loop-interval-tasks (:epoch (current-month-start)))
        (loop-interval-tasks (:epoch (current-month-start)))
        "last-month"
        (utils/loop-interval-tasks (:epoch (last-month-start))
                                   (:epoch (current-month-start)))
        (loop-interval-tasks (:epoch (last-month-start))
                             (:epoch (current-month-start)))
        "current-year"
        (utils/loop-interval-tasks (:epoch (current-year-start)))
        (loop-interval-tasks (:epoch (current-year-start)))
        "last-year"
        (utils/loop-interval-tasks (:epoch (start-of-year 1))
                                   (:epoch (current-year-start)))))))
        (loop-interval-tasks (:epoch (start-of-year 1))
                             (:epoch (current-year-start)))))))

(defn filter [brush]
  (fn [{:body body}]

M neil/watch/stats/utils.janet => neil/watch/stats/utils.janet +1 -1
@@ 24,7 24,7 @@
                    2 ~(and
                          (>= (w :start) ,(first epochs))
                          (<= (w :end) ,(last epochs)))))
  ~(utils/loop-tasks (worked-tasks brush project state ,;epochs)
  ~(loop-tasks (worked-tasks brush project state ,;epochs)
                     ,redseqcond
                     clients projects))