~pepe/neil

a372855fb2a6c85e46f9e3cdebff92895f318135 — Josef Pospíšil 2 months ago 0f68064
Use flatten
2 files changed, 13 insertions(+), 13 deletions(-)

M neil/guides.janet
M neil/watch/stats/utils.janet
M neil/guides.janet => neil/guides.janet +7 -8
@@ 70,10 70,9 @@
(def all-projects-table [:clients values (>: :projects) merged])

(def all-projects [;all-clients (>: :projects)
                   (>fn values) flatten])
                   flatvals])

(def all-tasks [;all-projects (>: :tasks)
                (>Y present?) (>fn values) flatten])
(def all-tasks [;all-projects (>: :tasks) (>Y present?) flatvals])

(defn state= [state] (fn _state= [i] (= (i :state) state)))



@@ 120,8 119,8 @@
(defn tasks-with-filter [brush filtr &opt limt]
  (default limt math/inf)
  (retrieve brush [;all-clients (>: :projects)
                   (<- merged) (>fn values) flatten
                   (>: :tasks) (>Y present?) (>fn values) flatten
                   (<- merged) flatvals
                   (>: :tasks) (>Y present?) flatvals
                   (>Y filtr) sort-by-timestamp (>n limt)
                   (<o> task-with-project-name-view)
                   <x]))


@@ 142,7 141,7 @@
  (retrieve
    brush
    [:clients (<-) values
     (>: :projects) (>fn values) flatten
     (>: :projects) flatvals
     (<o> project-with-client-view) <x
     sort-by-timestamp]))



@@ 188,8 187,8 @@

(defn active-tasks-match [q]
  [;all-clients (>: :projects)
   (<- merged) (>fn values) flatten
   (>: :tasks) (>Y present?) (>fn values) flatten
   (<- merged) flatvals
   (>: :tasks) (>Y present?) flatvals
   active? (>Y (name-has-match q)) (match-n-sort q)
   (limit 20) (>: 0) (<o> task-with-project-name-view)
   <x])

M neil/watch/stats/utils.janet => neil/watch/stats/utils.janet +6 -5
@@ 1,5 1,6 @@
(import /templates/stats/line)
(import /templates/work-intervals/csv-line)
(use /neil/watch/utils)

(defmacro loop-tasks [coll redseqcond clients projects]
  ~(do


@@ 22,11 23,11 @@
  (def redseqcond (case (length epochs)
                    1 ~(>= (w :start) ,(first epochs))
                    2 ~(and
                          (>= (w :start) ,(first epochs))
                          (<= (w :end) ,(last epochs)))))
  ~(loop-tasks (worked-tasks brush project state ,;epochs)
                     ,redseqcond
                     clients projects))
                         (>= (w :start) ,(first epochs))
                         (<= (w :end) ,(last epochs)))))
  ~(loop-tasks (,worked-tasks brush project state ,;epochs)
               ,redseqcond
               clients projects))

(defmacro loop-tasks-csv [coll redseqcond]
  ~(loop [{:uuid i :name n