more thoughts on graph algorithm

more thoughts on graph algorithm

--- src/clj/signet/graph.clj
+++ src/clj/signet/graph.clj
@@ -2,83 +2,111 @@
   (:require [clojure.set :refer [difference]]
             [aprint.core :refer [aprint]]))

-(def test-cg
-  {:causal-order {10 []
-                  20 [10]
-                  30 [20]
-                  40 [20]
-                  50 [40]
-                  60 [30 50]
-                  70 [60]
-                  80 [30]
-                  90 [80]
-                  100 [70]
-                  110 [100]
-                  120 [50]}
-   :branches {"master" 110
-              "fix" 120
-              "dev" 90}})
+
+(defmacro filter-map [bindings pred m]
+  `(select-keys ~m
+                (for [~bindings ~m
+                      :when ~pred]
+                  ~(first bindings))))

-(defn link-order [c causal-order heads]
+(defn branches->nodes [c causal-order heads]
   (loop [parents (get causal-order c)
          node c
-         order (list [c])]
-    (if (empty? parents)
+         order (list c)]
+    (if (nil? parents)
       order
       (if (< 2 (count parents))
         (recur (get causal-order  (first parents))
                (first parents)
-               (conj order [(first parents) node ]))
+               (conj order node))
         (let [next-node (first (remove heads parents))]
           (recur (get causal-order next-node)
                  next-node
-                 (conj order [next-node node ])))))))
+                 (conj order next-node)))))))

-(defn commit-graph->links [cg]
+(defn distinct-nodes [{:keys [nodes] :as cg}]
+  (assoc cg
+    :nodes
+    (loop [[b l-order] (first nodes)
+           b-list (rest nodes)
+           links []]
+      (if (empty? b-list)
+        (into {} (conj links [b l-order]))
+        (let [branch-diffs (map (fn [[k v]] [k (difference (set v) (set l-order))]) b-list)]
+          (recur
+           (first branch-diffs)
+           (rest branch-diffs)
+           (conj links [b (set l-order)])))))))
+
+
+(defn commit-graph->nodes [cg]
   (let [{:keys [branches causal-order]} cg
         heads (into #{} (vals branches))]
-    (loop [[b c] (first branches)
-           b-list (rest branches)
-           result []]
-      (if-not b
-        (sort-by second #(> (count %1) (count %2)) result)
-        (recur (first b-list)
-               (rest b-list)
-               (conj result [b (link-order c causal-order heads)]))))))
+    (assoc cg :nodes
+           (loop [[b c] (first branches)
+                  b-list (rest branches)
+                  result []]
+             (if-not b
+               (sort-by second #(> (count %1) (count %2)) result)
+               (recur (first b-list)
+                      (rest b-list)
+                      (conj result [b (branches->nodes c causal-order heads)])))))))

-(defn distinct-links [g]
-  (loop [[b l-order] (first g)
-         b-list (rest g)
-         links []]
-    (if (empty? b-list)
-      (into {} (conj links [b l-order]))
-      (let [branch-diffs (map (fn [[k v]] [k (difference (set v) (set l-order))]) b-list)]
-        (recur
-         (first branch-diffs)
-         (rest branch-diffs)
-         (conj links [b (set l-order)]))))))
-
-
-(defn distinct-nodes [g]
-  (into {} (map (fn [[k v]] [k (mapv first v)]) g)))
+(defn nodes->order
+  "doc-string"
+  [{:keys [nodes causal-order branches] :as cg}]
+  (let [new-nodes (map
+                   (fn [[b b-nodes]]
+                     [b (branches->nodes
+                         (get branches b)
+                         (select-keys causal-order b-nodes)
+                         (into #{} (vals branches)))])
+                   nodes)]
+    (assoc cg
+      :nodes
+      (->> new-nodes
+           (map (fn [[k v]] [k (rest v)]))
+           (into {}))
+      :branch-points
+      (->> new-nodes
+           (map (fn [[k v]] [k (first v)]))
+           (into {})))))

-(defn commit-graph->order [cg]
-  (let [g (commit-graph->links cg)
-        links (distinct-links g)]
-    {:nodes (distinct-nodes g)
-     :links links
-     :x-order (map first links)
-     :y-order (loop [old (map first links)
-                     new (list)
-                     i false]
-                (if (empty? old)
-                  new
-                  (recur (rest old)
-                         (if i
-                           (concat new (list (first old)))
-                           (concat (list (first old)) new))
-                         (not i))))}))
+
+(comment
+
+  (def test-cg
+    {:causal-order {10 []
+                    20 [10]
+                    30 [20]
+                    40 [20]
+                    50 [40]
+                    60 [30 50]
+                    70 [60]
+                    80 [30]
+                    90 [80]
+                    100 [70]
+                    110 [100]
+                    120 [90]}
+     :branches {"master" 110
+                "fix" 50
+                "dev" 120}})
+
+
+  (let [{:keys [causal-order branches]} (->> test-cg
+                                             commit-graph->nodes
+                                             distinct-nodes
+                                             nodes->order)
+        branch-heads (into {} (map (fn [[k v]] [v k]) branches))]
+    (map
+     (fn [[k v]]
+       [k ()])
+     (filter-map [key val] (> (count val) 1) causal-order)))
+
+
+
+  )


service logdriver 0.x -> 3.x

service logdriver 0.x -> 3.x

--- src/cljs/swarmpit/component/service/form_logdriver.cljs
+++ src/cljs/swarmpit/component/service/form_logdriver.cljs
@@ -1,7 +1,8 @@
 (ns swarmpit.component.service.form-logdriver
-  (:require [material.component :as comp]
+  (:require [material.icon :as icon]
+            [material.component :as comp]
             [material.component.form :as form]
-            [material.component.list-table-form :as list]
+            [material.component.list.edit :as list]
             [swarmpit.component.state :as state]
             [sablono.core :refer-macros [html]]
             [rum.core :as rum]))
@@ -12,61 +13,63 @@

 (def form-value-opts-cursor (conj form-value-cursor :opts))

-(def headers [{:name  "Name"
-               :width "35%"}
-              {:name  "Value"
-               :width "35%"}])
-
 (defn- form-driver [value]
-  (form/comp
-    "DRIVER"
-    (comp/select-field
-      {:value    value
-       :onChange (fn [_ _ v]
-                   (state/update-value [:name] v form-value-cursor))}
-      (comp/menu-item
-        {:key         "none"
-         :value       "none"
-         :primaryText "none"})
-      (comp/menu-item
-        {:key         "json-file"
-         :value       "json-file"
-         :primaryText "json-file"})
-      (comp/menu-item
-        {:key         "journald"
-         :value       "journald"
-         :primaryText "journald"}))))
+  (comp/text-field
+    {:fullWidth       true
+     :key             "form-log-driver"
+     :label           "Driver"
+     :select          true
+     :value           value
+     :variant         "outlined"
+     :InputLabelProps {:shrink true}
+     :onChange        #(state/update-value [:name] (-> % .-target .-value) form-value-cursor)}
+    (comp/menu-item
+      {:key   "none"
+       :value "none"} "none")
+    (comp/menu-item
+      {:key   "json-file"
+       :value "json-file"} "json-file")
+    (comp/menu-item
+      {:key   "journald"
+       :value "journald"} "journald")))

 (defn- form-name [value index]
-  (list/textfield
-    {:name     (str "form-name-text-" index)
-     :key      (str "form-name-text-" index)
-     :value    value
-     :onChange (fn [_ v]
-                 (state/update-item index :name v form-value-opts-cursor))}))
+  (comp/text-field
+    {:fullWidth       true
+     :label           "Name"
+     :key             (str "form-logdriver-opt-name-" index)
+     :value           value
+     :required        true
+     :variant         "outlined"
+     :InputLabelProps {:shrink true}
+     :onChange        #(state/update-item index :name (-> % .-target .-value) form-value-opts-cursor)}))

 (defn- form-value [value index]
-  (list/textfield
-    {:name     (str "form-value-text-" index)
-     :key      (str "form-value-text-" index)
-     :value    value
-     :onChange (fn [_ v]
-                 (state/update-item index :value v form-value-opts-cursor))}))
+  (comp/text-field
+    {:fullWidth       true
+     :label           "Value"
+     :key             (str "form-logdriver-opt-value-" index)
+     :value           value
+     :required        true
+     :variant         "outlined"
+     :InputLabelProps {:shrink true}
+     :onChange        #(state/update-item index :value (-> % .-target .-value) form-value-opts-cursor)}))

-(defn- render-variables
-  [item index]
-  (let [{:keys [name
-                value]} item]
-    [(form-name name index)
-     (form-value value index)]))
+(def form-metadata
+  [{:name      "Name"
+    :primary   true
+    :key       [:name]
+    :render-fn (fn [value _ index] (form-name value index))}
+   {:name      "Value"
+    :key       [:value]
+    :render-fn (fn [value _ index] (form-value value index))}])

 (defn- form-table
   [opts]
-  (list/table-raw headers
-                  opts
-                  nil
-                  render-variables
-                  (fn [index] (state/remove-item index form-value-opts-cursor))))
+  (list/responsive
+    form-metadata
+    opts
+    (fn [index] (state/remove-item index form-value-opts-cursor))))

 (defn- add-item
   []
@@ -75,9 +78,21 @@

 (rum/defc form < rum/reactive []
   (let [{:keys [name opts]} (state/react form-value-cursor)]
-    (form/form
-      {}
-      (form-driver name)
-      (html (form/subsection-add "Add log driver option" add-item))
-      (when (not (empty? opts))
-        (form-table opts)))))+    (comp/grid
+      {:container true
+       :spacing   40}
+      (comp/grid
+        {:item true
+         :xs   12
+         :sm   6} (form-driver name))
+      (comp/grid
+        {:item true
+         :xs   12}
+        (form/subsection
+          "Driver options"
+          (comp/button
+            {:color   "primary"
+             :onClick add-item}
+            (comp/svg icon/add-small) "Add option"))
+        (when (not (empty? opts))
+          (form-table opts))))))


CMR-2898 Clarifies docstring

CMR-2898 Clarifies docstring

--- access-control-app/src/cmr/access_control/api/routes.clj
+++ access-control-app/src/cmr/access_control/api/routes.clj
@@ -105,7 +105,7 @@
 ;; Misc route validations

 (defn system_object-concept_id-provider-target-validation
-  "Validates system_object and concept_id parameter lookup permissions."
+  "Validates presence and combinations of system_object, concept_id, provider, and target parameters."
   [{:keys [system_object concept_id provider target]}]
   (let [present? #(if (string? %)
                    (not (str/blank? %))


Added more HMAC functions; fixed small bug.

--- src/pandect/gen/core.clj
+++ src/pandect/gen/core.clj
@@ -112,8 +112,8 @@
                   (with-open [~sym (FileInputStream. this#)]
                     ~(stream->hmac code-gen sym k)))])
          nil
-         (~hash-f [this#] nil)
-         (~hmac-f [this#] nil)))))
+         ~@(when (support-hash? code-gen) [`(~hash-f [this#] nil)])
+         ~@(when (support-hmac? code-gen) [`(~hmac-f [this# k#] nil)])))))

 (defn- generate-compute-fns
   "Generate functions that call a prviously created hash function and wrap the result
@@ -124,17 +124,28 @@
    - `X-file` : input is path to file, outputs string
    - `X-file-bytes` : input is path to file, outputs byte array
    - `X*` : outputs the actual hash value generated by the given function
-   - `X*-file` : input is path to file, outputs the actual hash value generated by the given function
+   - `X-file*` : input is path to file, outputs the actual hash value generated by the given function
    - `X-hmac` : outputs HMAC string
+   - `X-hmac-bytes` : outputs HMAC byte array
+   - `X-hmac-file` : input is path to file, outputs HMAC string
+   - `X-hmac-file-bytes` : input is path to file, outputs HMAC byte array
+   - `X-hmac*` : outputs the actual hash value generated by the given HMAC function
+   - `X-hmac-file*` : input is path to file, outputs the actual hash value generated by the given HMAC function
+
+  The HMAC functions take two parameters: the input entity and a key that implements `ByteArrayConvertable`.
   "
   [code-gen id hash-f hmac-f]
   (let [id-bytes (symbol (str id "-bytes"))
         id-file (symbol (str id "-file"))
         id-file-bytes (symbol (str id "-file-bytes"))
         id-raw (symbol (str id "*"))
-        id-raw-file (symbol (str id "*-file"))
+        id-raw-file (symbol (str id "-file*"))
         id-hmac (symbol (str id "-hmac"))
+        id-hmac-bytes (symbol (str id "-hmac-bytes"))
         id-hmac-file (symbol (str id "-hmac-file"))
+        id-hmac-file-bytes (symbol (str id "-hmac-file-bytes"))
+        id-hmac-raw (symbol (str id "-hmac*"))
+        id-hmac-raw-file (symbol (str id "-hmac-file*"))
         sym (gensym "v")
         k (gensym "k")
         fsym (vary-meta sym assoc :tag `String)
@@ -145,7 +156,11 @@
     (concat
       (when (support-hmac? code-gen)
         (vector
+          `(defn ~id-hmac-raw [~sym ~k] ~call-hmac-direct)
+          `(defn ~id-hmac-raw-file [~fsym ~k] ~call-hmac-file)
+          `(defn ~id-hmac-bytes [~sym ~k] ~(hash->bytes code-gen call-hmac-direct))
           `(defn ~id-hmac-file [~sym ~k] ~(hash->string code-gen call-hmac-file))
+          `(defn ~id-hmac-file-bytes [~sym ~k] ~(hash->bytes code-gen call-hmac-file))
           `(defn ~id-hmac [~sym ~k] ~(hash->string code-gen call-hmac-direct))))
       (when (support-hash? code-gen)
         (vector


Uncomment stuff

Uncomment stuff

--- src/clj/algorithms_clj/ancestors.clj
+++ src/clj/algorithms_clj/ancestors.clj
@@ -107,7 +107,7 @@
     (println (get-grand-parents 'Herb))
     (println (get-couples))
     (println (get-all-siblings))
-    ;;(println (check-full-siblings? 'Alice 'Mike))
-    ;;(println (check-full-siblings? 'Alice 'Nicola))
+    (println (check-full-siblings? 'Alice 'Mike))
+    (println (check-full-siblings? 'Alice 'Philip))
     ))


Added basic DomainOps.

Added basic DomainOps.

--- src/clj/elephantdb/common/domain.clj
+++ src/clj/elephantdb/common/domain.clj
@@ -1,4 +1,5 @@
 (ns elephantdb.common.domain
+  (:refer-clojure :exclude (conj!))
   (:use [jackknife.def :only (defalias)])
   (:require [hadoop-util.core :as h]
             [hadoop-util.transfer :as transfer]
@@ -203,11 +204,27 @@
   (when-let [latest (newest-version domain)]
     (load-version! domain latest)))

-;; ## Domain Record Definition
+;; ## Domain Type Definition
+
+(defprotocol DomainOps
+  (index! [domain document]
+    "Indexes the supplied document into the domain."))

 (deftype Domain
     [localStore remoteStore serializer throttle rwLock
      hostname status domainData shardIndex]
+  DomainOps
+  (index! [this document]
+    ;; TODO: We need better error handling here. If a shard doesn't
+    ;; exist BUT is located in the shard-index, we should create the
+    ;; shard. load-version! should make sure that all shards are
+    ;; created.
+    (u/with-write-lock (.rwLock this)
+      ;; TODO: This will fail, currently. We need a way to toggle the
+      ;; readability.
+      (with-open [shard (retrieve-shard this document)]
+        (.index shard document))))
+
   clojure.lang.Seqable
   (seq [this]
     (when-let [data (domain-data this)]


fix register-sub and register-handler

fix register-sub and register-handler

--- src/cljs/phonecat_re_frame/core.cljs
+++ src/cljs/phonecat_re_frame/core.cljs
@@ -34,29 +34,19 @@
    (reaction (:order-prop @db))))

 (re-frame/register-handler
- :initialise-db             ;; usage: (dispatch [:initialise-db])
- (fn
-   [_ _]                   ;; Ignore both params (db and v).
-   {:phones [{:name "Nexus S" :snippet "Fast just got faster with Nexus S."}
-             {:name "Motorola XOOM™ with Wi-Fi" :snippet "The Next, Next Generation tablet."}
-             {:name "Motoral Xoom" :snippet "The Next, Next Generation tablet."}]
-    :search-input ""
-    :order-prop "name"}))
-
-(re-frame/register-pure-handler
  :process-phones-response
  (fn
    [app-state [_ response]]
    (assoc-in app-state [:phones] response)))

-(re-frame/register-pure-handler
+(re-frame/register-handler
  :process-phones-bad-response
  (fn
    [app-state [_ response]]
    (println "Error getting phones" response)
    app-state))

-(re-frame/register-pure-handler
+(re-frame/register-handler
  :load-phones
  (fn
    [app-state _]
@@ -67,20 +57,19 @@
                    :keywords? true})
    app-state))

-(re-frame/register-pure-handler
-   :initialise-db             ;; usage: (dispatch [:initialise-db])
-   (fn
-     [_ _]                   ;; Ignore both params (db and v).
-     {:phones []
-      :search-input ""
-      :order-prop "name"}))
+(re-frame/register-handler
+ :initialise-db             ;; usage: (dispatch [:initialise-db])
+ (fn
+   [_ _]                   ;; Ignore both params (db and v).
+   {:phones []
+    :search-input ""
+    :order-prop "name"}))

 (defn handle-search-input-entered
   [app-state [_ search-input]]
   (assoc-in app-state [:search-input] search-input))

 (re-frame/register-handler
-<<<<<<< HEAD
  :search-input-entered
  handle-search-input-entered)

@@ -145,15 +134,6 @@
        [:select {:on-change #(re-frame/dispatch [:order-prop-changed (-> % .-target .-value)])}
         [:option (mark-selected {:value "name"} @order-prop "name") "Alphabetical"]
         [:option (mark-selected {:value "age"} @order-prop "age") "Newest"]]])))
-<<<<<<< HEAD
-
-(defn phones-component
-  []
-  (let [phones (re-frame/subscribe [:phones])]
-    (fn []
-      [:ul (doall  (map (fn [phone] ^{:key phone} [phone-component (:name phone) (:snippet phone)]) @phones))])))
-=======
->>>>>>> 010187c... basic clean up

 (defn home-page []
   [phones-component])


mass plays easy now

mass plays easy now

--- src/cljs/western_music/handlers.cljs
+++ src/cljs/western_music/handlers.cljs
@@ -93,24 +93,22 @@
   (fn [all-data [_ composer-id]]
     (ui/enqueue-composer all-data composer-id)))

-(reg-event-db
+(reg-event-fx
   :play-composer
-  (fn [all-data [_ composer-id]]
-    (-> all-data
-        (ui/enqueue-composer composer-id)
-        (update-in ui/player-path ui/player-play))))
+  (fn [{db :db} [_ composer-id]]
+    {:db (ui/enqueue-composer db composer-id)
+     :dispatch [:player-play]}))

 (reg-event-db
   :enqueue-nation
   (fn [all-data [_ nation-id]]
     (ui/enqueue-nation all-data nation-id)))

-(reg-event-db
+(reg-event-fx
   :play-nation
-  (fn [all-data [_ nation-id]]
-    (-> all-data
-        (ui/enqueue-nation nation-id)
-        (update-in ui/player-path ui/player-play))))
+  (fn [{db :db} [_ nation-id]]
+    {:db (ui/enqueue-nation db nation-id)
+     :dispatch [:player-play]}))

 (reg-event-fx
   :dequeue-track


Add another pointless variable

Add another pointless variable


Removing reflection warning from c.fca.association-rules

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/fca/association_rules.clj
+++ src/conexp/fca/association_rules.clj
@@ -50,7 +50,7 @@
   ([^Association-Rule ar]
      (.confidence ar)))

-(defmethod print-method Association-Rule [ar out]
+(defmethod print-method Association-Rule [ar, ^java.io.Writer out]
   (.write out
           (str "( " (premise ar) " ==> " (conclusion ar)
                "; support " (support ar)


Fixing highlighting test so that it is not dependent on order.

--- system-int-test/test/cmr/system_int_test/search/collection_highlights_search_test.clj
+++ system-int-test/test/cmr/system_int_test/search/collection_highlights_search_test.clj
@@ -24,7 +24,8 @@
   (->> search-results
        :results
        :entries
-       (map :highlighted-summary-snippets)))
+       (map :highlighted-summary-snippets)
+       set))

 (defn- ingest-collections-for-test
   "Ingest all of the collections that will be used for testing"
@@ -48,7 +49,7 @@
   (ingest-collections-for-test)
   (util/are2
     [expected-results search-params options]
-    (= expected-results
+    (= (set expected-results)
        (get-search-results-summaries
          (search/find-concepts-json :collection (merge {:include-highlights true} search-params options))))

@@ -108,10 +109,11 @@
   (ingest-collections-for-test)
   (util/are2
     [expected-results json-query-conditions options]
-    (= expected-results (get-search-results-summaries (search/find-concepts-in-json-with-json-query
-                                                        :collection
-                                                        (merge {:include-highlights true} options)
-                                                        json-query-conditions)))
+    (= (set expected-results)
+       (get-search-results-summaries (search/find-concepts-in-json-with-json-query
+                                      :collection
+                                      (merge {:include-highlights true} options)
+                                      json-query-conditions)))

     "JSON Query keyword with spaces treats as two separate keywords AND'ed together"
     [["Match on either 'ocean' or 'collection'."]
@@ -212,11 +214,11 @@
 (deftest special-characters-test
   (make-coll 1 {:summary "MODIS/Terra dataset."})
   (index/wait-until-indexed)
-  (is (= [["MODIS/Terra dataset."]]
+  (is (= #{["MODIS/Terra dataset."]}
          (get-search-results-summaries (search/find-concepts-in-json-with-json-query
-                                         :collection
-                                         {:include-highlights true}
-                                         {:keyword "MODIS/Terra"})))))
+                                        :collection
+                                        {:include-highlights true}
+                                        {:keyword "MODIS/Terra"})))))

 (deftest reserved-characters-test
   ;; This test documents the current elasticsearch highlighting behavior with respect to reserved
@@ -232,30 +234,30 @@

     (testing "Most reserved characters are not highlighted when they are searched against."
       (doseq [reserved-string (set/difference reserved-strings
-                                              reserved-strings-with-different-behavior)]
-        (is (= [[(format "MODIS%sTERRA dataset." reserved-string)]]
+                                reserved-strings-with-different-behavior)]
+        (is (= #{[(format "MODIS%sTERRA dataset." reserved-string)]}
                (get-search-results-summaries (search/find-concepts-in-json-with-json-query
-                                               :collection
-                                               {:include-highlights true}
-                                               {:keyword (format "MODIS%sTERRA"
-                                                                 reserved-string)}))))))
+                                              :collection
+                                              {:include-highlights true}
+                                              {:keyword (format "MODIS%sTERRA"
+                                                                reserved-string)}))))))

     (testing "Colons are highlighted along with the search string."
-      (is (= [["MODIS:TERRA dataset."]]
+      (is (= #{["MODIS:TERRA dataset."]}
              (get-search-results-summaries (search/find-concepts-in-json-with-json-query
-                                             :collection
-                                             {:include-highlights true}
-                                             {:keyword "MODIS:TERRA"})))))
+                                            :collection
+                                            {:include-highlights true}
+                                            {:keyword "MODIS:TERRA"})))))

     (testing "Wildcard searches do not highlight any strings with reserved characters except for
              colon."
-             (doseq [reserved-string #{"*" "?"}]
-               (is (= (set [nil ["MODIS:TERRA dataset."]])
-                      (set (get-search-results-summaries
-                             (search/find-concepts-in-json-with-json-query
-                                                           :collection
-                                                           {:include-highlights true
-                                                            :page-size 1000}
-                                                           {:keyword (format "MODIS%sTERRA"
-                                                                             reserved-string)})))))))))
-
+      (doseq [reserved-string #{"*" "?"}]
+        (is (= (set [nil ["MODIS:TERRA dataset."]])
+               (get-search-results-summaries
+                (search/find-concepts-in-json-with-json-query
+                 :collection
+                 {:include-highlights true
+                  :page-size 1000}
+                 {:keyword (format "MODIS%sTERRA"
+                                   reserved-string)}))))))))
+


switch back to running non-sample databases for sync task.

--- src/metabase/task/sync_databases.clj
+++ src/metabase/task/sync_databases.clj
@@ -20,7 +20,7 @@
 (jobs/defjob SyncDatabases
   [ctx]
   (dorun
-    (for [database (db/sel :many Database :is_sample true)] ; skip Sample Dataset DB
+    (for [database (db/sel :many Database :is_sample false)] ; skip Sample Dataset DB
       (try
         ;; NOTE: this happens synchronously for now to avoid excessive load if there are lots of databases
         (if-not (and (= 0 (t/hour (t/now)))


UI sent null value

UI sent null value

--- src/tango/cljs/adjudicator/core.cljs
+++ src/tango/cljs/adjudicator/core.cljs
@@ -209,26 +209,26 @@
                                 "mark-disabled"
                                 "mark")
                    :disabled  true
-                   :onClick
-                              #(if-not (and (not (:allow-marks? (om/props this)))
-                                            (not mark-x))
-                                (let [mark-value (if (or (:allow-marks? (om/props this))
-                                                         (and (not (:allow-marks? (om/props this)))
-                                                              mark-x))
-                                                   (.. % -target -checked)
-                                                   mark-x)]
-                                  (om/transact!
-                                    reconciler
-                                    `[(participant/set-result
-                                        {:result/id          ~(if (:result/id (:result (om/props this)))
-                                                                (:result/id (:result (om/props this)))
-                                                                (random-uuid))
-                                         :result/mark-x      ~mark-value
-                                         :result/point       ~point
-                                         :result/participant ~(:participant/id (om/props this))
-                                         :result/activity    ~(:activity/id (om/props this))
-                                         :result/adjudicator ~(:adjudicator/id (om/props this))})
-                                      :app/results])))}
+                   ;:onClick #(if-not (and (not (:allow-marks? (om/props this)))
+                   ;                         (not mark-x))
+                   ;             (let [mark-value (if (or (:allow-marks? (om/props this))
+                   ;                                      (and (not (:allow-marks? (om/props this)))
+                   ;                                           mark-x))
+                   ;                                (.. % -target -checked)
+                   ;                                mark-x)]
+                   ;               (om/transact!
+                   ;                 reconciler
+                   ;                 `[(participant/set-result
+                   ;                     {:result/id          ~(if (:result/id (:result (om/props this)))
+                   ;                                             (:result/id (:result (om/props this)))
+                   ;                                             (random-uuid))
+                   ;                      :result/mark-x      ~mark-value
+                   ;                      :result/point       ~point
+                   ;                      :result/participant ~(:participant/id (om/props this))
+                   ;                      :result/activity    ~(:activity/id (om/props this))
+                   ;                      :result/adjudicator ~(:adjudicator/id (om/props this))})
+                   ;                   :app/results])))
+                   }
               (dom/h1 #js {:className "mark-text"
                            } (if (:result/mark-x (:result (om/props this)))
                                "X"


Made component for heat row

Made component for heat row

--- src/tango/cljs/adjudicator/core.cljs
+++ src/tango/cljs/adjudicator/core.cljs
@@ -153,6 +153,23 @@
 ;                coll))

 ;(fn [idx x] (str idx)) (partition-all (int (Math/ceil (/ 40 7))) (range 1 41)))
+
+(defui HeatRowComponent
+  static om/IQuery
+  (query [_])
+  Object
+  (render [this]
+    (dom/div nil
+      (dom/h4 nil (:participant/number (om/props this)))
+      (dom/div #js {:className "checkbox"}
+        (dom/label nil
+          (dom/input #js {:type     "checkbox"
+                          :checked  true
+                          :onChange #(.. % -target -checked)})))
+      (dom/button nil "+")
+      (dom/button nil "-")
+      (dom/h4 nil "2p"))))
+
 (defui HeatComponent
   static om/IQuery
   (query [_])
@@ -160,7 +177,9 @@
   (render [this]
     (let [heat (:heat (om/props this))
           participants (:participants (om/props this))]
-      (dom/div nil (str "Heat : " heat)))))
+      (dom/div #js {:className "col-sm-4"}
+        (dom/h3 nil "Heat : " (str (+ 1 heat)))
+        (map #((om/factory HeatRowComponent) %) participants)))))

 (defui HeatsComponent
   static om/IQuery
@@ -170,7 +189,8 @@
   (render [this]
     (let [participants (:participants (om/props this))
           heats (:heats (om/props this))
-          heat-parts (partition-all (int (Math/ceil (/ (count participants) heats))) participants)]
+          heat-parts (partition-all (int (Math/ceil (/ (count participants) heats)))
+                                    (sort-by :participant/number participants))]
       (dom/div nil
         (dom/h3 nil (str "Heats : " heats))
         (map-indexed (fn [idx parts] ((om/factory HeatComponent)


minor stress test changes

minor stress test changes

--- test/acceptance/new_stress_tests.clj
+++ test/acceptance/new_stress_tests.clj
@@ -21,9 +21,9 @@
 ;;;;

 (defn run-program-in-standardized-interpreter
-  [interpreter program bindings]
+  [id interpreter program bindings]
   (do
-    (println (str "\n\n\nrunning: " program))
+    (println (str "\n\n\nrunning " id " : " program))
     (push/run
       interpreter
       program
@@ -124,6 +124,7 @@
             (first %) ": "
             (interpreter-details
               (run-program-in-standardized-interpreter
+                (first %)
                 interpreter
                 (second %)
                 bindings))))


Added entry linking tests.

Added entry linking tests.

--- test/lambda_blog/middleware_test.clj
+++ test/lambda_blog/middleware_test.clj
@@ -1,6 +1,6 @@
 (ns lambda-blog.middleware-test
   (:require [clojure.test :refer :all]
-            [lambda-blog.middleware :refer [add-paths collect-tags]]
+            [lambda-blog.middleware :refer [add-paths collect-tags link]]
             [lambda-blog.generator :refer [update-all]]))

 (deftest can-generate-paths-from-spec
@@ -51,3 +51,18 @@
     (let [ent {:entries [entry1 entry2 entry3]}]
       (is (= (collect-tags ent)
              (assoc ent :tags #{{:id :foo} {:id :bar}}))))))
+
+(deftest linking-entries-works
+  (let [es [{:title 1} {:title 2} {:title 3}]
+        linked ((link :entries) {:entries es})
+        les (:entries linked)]
+    (is (= (:previous (first les))
+           nil))
+    (is (= (:next (first les))
+           {:title 2}))
+    (is (= (:previous (second les))
+           {:title 1}))
+    (is (= (:next (second les))
+           {:title 3}))
+    (is (= (:next (nth les 2))
+           nil))))


Add "unit" to caddisfly "name" response

Add "unit" to caddisfly "name" response

--- backend/src/akvo/lumen/lib/multiple_column.clj
+++ backend/src/akvo/lumen/lib/multiple_column.clj
@@ -9,7 +9,7 @@
       (let [res (select-keys schema [:hasImage])]
         (assoc res :columns (map (fn [r]
                                    {:id   (:id r)
-                                    :name (:name r)
+                                    :name (format "%s (%s)" (:name r) (:unit r))
                                     :type "text" ;; TODO will be improved after design discussions
                                     }) (:results schema)))))))


CMR-5397: Move defn to def.

CMR-5397: Move defn to def.

--- collection-renderer-lib/src/cmr/collection_renderer/services/collection_renderer.clj
+++ collection-renderer-lib/src/cmr/collection_renderer/services/collection_renderer.clj
@@ -33,12 +33,11 @@
   "Defines the path to the UMM schema version config file within the preview gem."
   "gems/cmr_metadata_preview-0.0.1/.umm-version")

-(defn- create-jruby-runtime
+(def ^:private create-jruby-runtime
   "Creates and initializes a JRuby runtime. We do this as a future to speed up REPL start time
   by more than one minute. Worst case is the first request to retrieve HTML after the search app
   starts takes one minute, but in practice NGAP usually takes around one minute from the time an app
   is started to put it in the load balancer, so this is not an operational concern."
-  []
   (future
     (let [jruby (.. (ScriptEngineManager.)
                     (getEngineByName "jruby"))
@@ -57,7 +56,7 @@

 ;; Allows easily evaluating Ruby code in the Clojure REPL.
 (comment
- (def jruby (create-jruby-runtime))
+ (def jruby create-jruby-runtime)

  (defn eval-jruby
    [s]
@@ -75,7 +74,7 @@
   (start
    [this _system]
    (-> this
-       (assoc :jruby-runtime (create-jruby-runtime))
+       (assoc :jruby-runtime create-jruby-runtime)
        (assoc :preview-gem-umm-version (get-preview-gem-umm-version))))


spacing

spacing

--- src/babel/parse.cljc
+++ src/babel/parse.cljc
@@ -198,7 +198,7 @@
                                                        (string/join ","
                                                                     (map #(morph-ps %) right-signs))))
                                        (if parse-with-truncate truncated-parents parents)))
-                                 ;; TODO: explain why we can use (first) here for the left- and right-strings.
+                                   ;; TODO: explain why we can use (first) here for the left- and right-strings.
                                    ;; Throw an exception if (> 1 (count left-strings)) or (> 1 (count right-strings))
                                    [(string/join " " [(first left-strings) (first right-strings)])]))
                                 ;; </value>


Should not use underscores in this way in Clojure.

--- clojure-functional/src/test/clojure/no/knowit/clojure_functional/product_repository.clj
+++ clojure-functional/src/test/clojure/no/knowit/clojure_functional/product_repository.clj
@@ -5,7 +5,7 @@

 ; Production code

-; Use filter and provide your own function. Remember how you call a native Java method?
+;; Use filter and provide your own function. Remember how you call a native Java method?
 (defn product-is-available [local-date product-coll]
   (filter
     #(.isAvailable %1 local-date) product-coll))
@@ -24,16 +24,16 @@
 (def product-func product-is-available)

 ; Test code
-(deftest empty_list_when_no_products
+(deftest empty-list-when-no-products
   (is (= (product-func (LocalDate.) []))))

-(deftest product_available_when_matching_date
+(deftest product-available-when-matching-date
   (let [today (new LocalDate)
         product (new Product "Cool product" today today)]
     (is (not-empty (product-func today [product])))
     (is (.contains (product-func today [product]) product))))

-(deftest empty_list_when_no_products_matching_date
+(deftest empty-list-when-no-products-matching-date
   (let [today (new LocalDate)
         yesterday (.minusDays today 1)
         product (new Product "Cool product" yesterday yesterday)]
@@ -46,7 +46,7 @@
         product-two (new Product "Todays product" today today)]
     (is (= 1 (count (product-func today [product-one product-two]))))))

-(deftest find_discontinued_products
+(deftest find-discontinued-products
   (let [yesterday (.minusDays (new LocalDate) 1)
         product (new Product "Cool product" yesterday yesterday)]
     (is (not-empty (product-func yesterday [product])))))


CMR-3069: Addressing TODO

CMR-3069: Addressing TODO

--- common-app-lib/src/cmr/common_app/services/search/validators/max_number_of_conditions.clj
+++ common-app-lib/src/cmr/common_app/services/search/validators/max_number_of_conditions.clj
@@ -29,7 +29,7 @@
       1)))

 (defn validate
-  "TODO"
+  "Validates that a query does not contain more than the configured maximum number of conditions"
   [query]
   (let [num-conditions (count-conditions query)]
     (debug "Query contained" num-conditions "conditions")


info removal

info removal

--- src/clj_hypergraph_db/hdm_parser/hdm_uml_model_manager.clj
+++ src/clj_hypergraph_db/hdm_parser/hdm_uml_model_manager.clj
@@ -36,7 +36,6 @@
   [class-instance-handle class-name attribute-name attribute-data]
   (let [attribute-handle (:handle ((get-all-attributes class-name) attribute-name))
         instance-handle (add-node attribute-data)]
-    (println "It'z working...? "  attribute-handle " " attribute-name)
     (add-link :instance (list attribute-handle instance-handle))
     (add-link attribute-name (list class-instance-handle instance-handle))
     instance-handle))


(PE-6018) Fix ref to PuppetDB and pred fn name

--- src/clj/puppetlabs/services/version/version_check_core.clj
+++ src/clj/puppetlabs/services/version/version_check_core.clj
@@ -35,13 +35,13 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Private

-(defn schema-match
+(defn schema-match?
   [schema obj]
   (nil? (schema/check schema obj)))

 (schema/defn get-coords :- ProductCoords
   [product-name :- ProductName]
-  (condp schema-match product-name
+  (condp schema-match? product-name
     schema/Str {:group-id default-group-id
                 :artifact-id product-name}
     ProductCoords product-name))
@@ -53,7 +53,7 @@
   (version/get-version group-id artifact-id))

 (def version
-  "Get the version number of this PuppetDB installation."
+  "Get the version number of this installation."
   (memoize version*))

 (schema/defn ^:always-validate update-info :- (schema/maybe UpdateInfo)


break apart table into component functions

--- src/cljs/org/broadinstitute/firecloud_ui/common/table.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/common/table.cljs
@@ -21,6 +21,7 @@
    :starting-width (or (:starting-width props) 200)
    :as-text #(common/format-date % (:format props))})

+(declare initial-table-state render-table refresh-table-rows)

 ;; Table component with specifiable style and column behaviors.
 ;;
@@ -153,166 +154,15 @@
               (persistence/try-restore
                {:key (:state-key props)
                 :validator (fn [stored-value] (= (set (keys stored-value)) persistence-keys))
-                :initial
-                (fn [] (let [processed-columns (if-let [defaults (:column-defaults props)]
-                                                 (let [by-header (utils/index-by :header (:columns props))
-                                                       default-showing (->> defaults
-                                                                            (replace by-header)
-                                                                            (map #(assoc % :show-initial? true)))
-                                                       default-hiding (as-> by-header $
-                                                                            (apply dissoc $ defaults)
-                                                                            (vals $)
-                                                                            (map #(assoc % :show-initial? false) $))]
-                                                   (concat default-showing default-hiding))
-                                                 (:columns props))
-                             column-meta (vec (map (fn [{:keys [header header-key starting-width] :as col}]
-                                                     {:header (or header-key header)
-                                                      :width (or starting-width 100)
-                                                      :visible? (get col :show-initial? true)})
-                                                   processed-columns))
-                             initial-sort-column (or (some->> (:columns props)
-                                                              (filter #(contains? % :sort-initial))
-                                                              first)
-                                                     (when (:always-sort? props)
-                                                       (first (:columns props))))]
-                         {:column-meta column-meta
-                          :filter-group-index (get props :initial-filter-group-index 0)
-                          :query-params (merge
-                                         {:current-page 1 :rows-per-page initial-rows-per-page
-                                          :filter-text ""}
-                                         (when initial-sort-column
-                                           {:sort-column (:header initial-sort-column)
-                                            ; default needed when forcing sort
-                                            :sort-order (or (:sort-initial initial-sort-column) :asc)}))}))}))))
-   :render
-   (fn [{:keys [this state props refs after-update]}]
-     (assert (vector? (:column-meta @state)) "column-meta got un-vec'd")
-     (let [{:keys [filterable? reorderable-columns? toolbar retain-header-on-empty?]} props
-           {:keys [no-data? error]} @state
-           any-width=remaining? (->> (:column-meta @state)
-                                     (map :width)
-                                     (some (partial = :remaining)))]
-       [:div {}
-        (when (or filterable? reorderable-columns? toolbar)
-          (let [built-in
-                [:div {:style {:paddingBottom "1em"}}
-                 (when reorderable-columns?
-                   [:div {:style {:float "left"}}
-                    [comps/Button {:icon :settings :title-text "Select Columns..."
-                                   :ref "col-edit-button"
-                                   :onClick #(swap! state assoc :reordering-columns? true)}]
-                    (when (:reordering-columns? @state)
-                      [overlay/Overlay
-                       {:get-anchor-dom-node #(react/find-dom-node (@refs "col-edit-button"))
-                        :dismiss-self #(swap! state assoc :reordering-columns? false)
-                        :content
-                        (react/create-element
-                         table-utils/ColumnEditor
-                         {:columns (react/call :get-ordered-columns this)
-                          :on-reorder
-                          (fn [source-index target-index]
-                            (swap! state update :column-meta utils/move source-index target-index))
-                          :on-visibility-change
-                          (fn [column-index visible?]
-                            (if (= :all column-index)
-                              (swap! state update :column-meta #(vec (map merge % (repeat {:visible? visible?}))))
-                              (swap! state assoc-in [:column-meta column-index :visible?] visible?)))})}])])
-                 (when filterable?
-                   [:div {:style {:float "left" :marginLeft "1em"}}
-                    [table-utils/TextFilter {:initial-text (get-in @state [:query-params :filter-text])
-                                             :on-filter #(swap! state update-in [:query-params]
-                                                                assoc :filter-text % :current-page 1)}]])
-                 (when (:filter-groups props)
-                   [:div {:style {:float "left" :marginLeft "1em" :marginTop -3}}
-                    [table-utils/FilterGroupBar
-                     (merge (select-keys props [:filter-groups :data])
-                            {:selected-index (:filter-group-index @state)
-                             :on-change (fn [new-index]
-                                          (swap! state assoc :filter-group-index new-index)
-                                          (after-update #(react/call :refresh-rows this))
-                                          (when-let [f (:on-filter-change props)]
-                                            (f new-index)))})]])
-                 (common/clear-both)]]
-            ((or toolbar identity) built-in)))
-        [:div {:style {:position "relative"}}
-         [comps/DelayedBlocker {:ref "blocker" :banner "Loading..."}]
-         ;; When using an auto-width column the table ends up ~1px wider than its parent
-         [:div {:style {:overflowX (if any-width=remaining? "hidden" "auto")}}
-          [:div {:style {:position "relative"
-                         :paddingBottom 10
-                         :minWidth (when-not (or no-data? any-width=remaining?)
-                                     (->> (react/call :get-ordered-columns this)
-                                          (filter :visible?)
-                                          (map :width)
-                                          (apply +)))
-                         :cursor (when (:dragging? @state) "col-resize")}}
-           (when (or (not no-data?) retain-header-on-empty?)
-             (table-utils/render-header state props this))
-           (when error
-             [:div {:style {:padding "0.5em"}}
-              (style/create-server-error-message error)])
-           (when (and (not error) no-data?)
-             (style/create-message-well (or (:empty-message props) "There are no rows to display.")))
-           [table-utils/Body
-            (assoc props
-              :columns (filter :visible? (react/call :get-ordered-columns this))
-              :rows (:display-rows @state))]]]]
-        (when-not (= (:pagination props) :none)
-          [:div {:style {:paddingTop (:paginator-space props)}}
-           [table-utils/Paginator
-            {:width (:width props)
-             :pagination-params (select-keys (:query-params @state) [:current-page :rows-per-page])
-             :num-visible-rows (:filtered-count @state)
-             :num-total-rows (or (:num-total-rows props) (:grouped-count @state))
-             :on-change #(swap! state update-in [:query-params] merge %)
-             :initial-rows-per-page (get-in @state [:query-params :rows-per-page])}]])]))
+                :initial #(initial-table-state props)}))))
+   :render render-table
    :get-ordered-columns
    (fn [{:keys [state]}]
      (->> (:column-meta @state)
           (map (fn [{:keys [header] :as column-meta}]
                  (merge column-meta (get (:given-columns-by-header @state) header))))
           vec))
-   :refresh-rows
-   (fn [{:keys [props state refs]}]
-     (react/call :show (@refs "blocker"))
-     (let [{:keys [pagination data ->row]} props]
-       (if (fn? pagination)
-         (pagination (merge (select-keys @state [:filter-group-index]) (:query-params @state))
-                     (fn [{:keys [group-count filtered-count rows error]}]
-                       (react/call :hide (@refs "blocker"))
-                       (swap! state assoc
-                              :grouped-count group-count
-                              :filtered-count filtered-count
-                              :display-rows (map ->row rows)
-                              :no-data? (empty? rows)
-                              :error error)))
-         (let [{:keys [current-page rows-per-page sort-column sort-order filter-text]} (:query-params @state)
-               grouped-data (if-not (:filter-groups props)
-                              data
-                              (filter (:pred (get-in props [:filter-groups (:filter-group-index @state)]))
-                                      data))
-               filtered-data (if-let [txt (not-empty filter-text)]
-                               (table-utils/filter-data grouped-data ->row (:columns props) txt)
-                               grouped-data)
-               rows (map ->row filtered-data)
-               sorted-rows (if sort-column
-                             (let [column (get (:given-columns-by-header @state) sort-column)
-                                   column-index (utils/first-matching-index (fn [{:keys [header]}] (= header sort-column)) (:column-meta @state))
-                                   key-fn (or (:sort-by column) identity)
-                                   key-fn (if (= key-fn :text) (:as-text column) key-fn)]
-                               (sort-by (fn [row] (key-fn (nth row column-index))) rows))
-                             rows)
-               ordered-rows (if (= :desc sort-order) (reverse sorted-rows) sorted-rows)
-               ;; realize this sequence so errors can be caught early:
-               clipped-rows (if (= pagination :none)
-                              ordered-rows
-                              (doall (take rows-per-page (drop (* (dec current-page) rows-per-page) ordered-rows))))]
-           (react/call :hide (@refs "blocker"))
-           (swap! state assoc
-                  :grouped-count (count grouped-data)
-                  :filtered-count (count filtered-data)
-                  :display-rows clipped-rows
-                  :no-data? (empty? clipped-rows))))))
+   :refresh-rows refresh-table-rows
    :component-did-mount
    (fn [{:keys [this state locals]}]
      (swap! locals assoc :initial-state (select-keys @state persistence-keys))
@@ -349,3 +199,160 @@
    (fn [{:keys [this]}]
      (.removeEventListener js/window "mousemove" (.-onMouseMoveHandler this))
      (.removeEventListener js/window "mouseup" (.-onMouseUpHandler this)))})
+
+
+
+(defn- initial-table-state [props]
+  (let [processed-columns (if-let [defaults (:column-defaults props)]
+                            (let [by-header (utils/index-by :header (:columns props))
+                                  default-showing (->> defaults
+                                                       (replace by-header)
+                                                       (map #(assoc % :show-initial? true)))
+                                  default-hiding (as-> by-header $
+                                                       (apply dissoc $ defaults)
+                                                       (vals $)
+                                                       (map #(assoc % :show-initial? false) $))]
+                              (concat default-showing default-hiding))
+                            (:columns props))
+        column-meta (vec (map (fn [{:keys [header header-key starting-width] :as col}]
+                                {:header (or header-key header)
+                                 :width (or starting-width 100)
+                                 :visible? (get col :show-initial? true)})
+                              processed-columns))
+        initial-sort-column (or (some->> (:columns props)
+                                         (filter #(contains? % :sort-initial))
+                                         first)
+                                (when (:always-sort? props)
+                                  (first (:columns props))))]
+    {:column-meta column-meta
+     :filter-group-index (get props :initial-filter-group-index 0)
+     :query-params (merge
+                    {:current-page 1 :rows-per-page initial-rows-per-page
+                     :filter-text ""}
+                    (when initial-sort-column
+                      {:sort-column (:header initial-sort-column)
+                       ; default needed when forcing sort
+                       :sort-order (or (:sort-initial initial-sort-column) :asc)}))}))
+
+(defn- render-table [{:keys [this state props refs after-update]}]
+  (assert (vector? (:column-meta @state)) "column-meta got un-vec'd")
+  (let [{:keys [filterable? reorderable-columns? toolbar retain-header-on-empty?]} props
+        {:keys [no-data? error]} @state
+        any-width=remaining? (->> (:column-meta @state)
+                                  (map :width)
+                                  (some (partial = :remaining)))]
+    [:div {}
+     (when (or filterable? reorderable-columns? toolbar)
+       (let [built-in
+             [:div {:style {:paddingBottom "1em"}}
+              (when reorderable-columns?
+                [:div {:style {:float "left"}}
+                 [comps/Button {:icon :settings :title-text "Select Columns..."
+                                :ref "col-edit-button"
+                                :onClick #(swap! state assoc :reordering-columns? true)}]
+                 (when (:reordering-columns? @state)
+                   [overlay/Overlay
+                    {:get-anchor-dom-node #(react/find-dom-node (@refs "col-edit-button"))
+                     :dismiss-self #(swap! state assoc :reordering-columns? false)
+                     :content
+                     (react/create-element
+                      table-utils/ColumnEditor
+                      {:columns (react/call :get-ordered-columns this)
+                       :on-reorder
+                       (fn [source-index target-index]
+                         (swap! state update :column-meta utils/move source-index target-index))
+                       :on-visibility-change
+                       (fn [column-index visible?]
+                         (if (= :all column-index)
+                           (swap! state update :column-meta #(vec (map merge % (repeat {:visible? visible?}))))
+                           (swap! state assoc-in [:column-meta column-index :visible?] visible?)))})}])])
+              (when filterable?
+                [:div {:style {:float "left" :marginLeft "1em"}}
+                 [table-utils/TextFilter {:initial-text (get-in @state [:query-params :filter-text])
+                                          :on-filter #(swap! state update-in [:query-params]
+                                                             assoc :filter-text % :current-page 1)}]])
+              (when (:filter-groups props)
+                [:div {:style {:float "left" :marginLeft "1em" :marginTop -3}}
+                 [table-utils/FilterGroupBar
+                  (merge (select-keys props [:filter-groups :data])
+                         {:selected-index (:filter-group-index @state)
+                          :on-change (fn [new-index]
+                                       (swap! state assoc :filter-group-index new-index)
+                                       (after-update #(react/call :refresh-rows this))
+                                       (when-let [f (:on-filter-change props)]
+                                         (f new-index)))})]])
+              (common/clear-both)]]
+         ((or toolbar identity) built-in)))
+     [:div {:style {:position "relative"}}
+      [comps/DelayedBlocker {:ref "blocker" :banner "Loading..."}]
+      ;; When using an auto-width column the table ends up ~1px wider than its parent
+      [:div {:style {:overflowX (if any-width=remaining? "hidden" "auto")}}
+       [:div {:style {:position "relative"
+                      :paddingBottom 10
+                      :minWidth (when-not (or no-data? any-width=remaining?)
+                                  (->> (react/call :get-ordered-columns this)
+                                       (filter :visible?)
+                                       (map :width)
+                                       (apply +)))
+                      :cursor (when (:dragging? @state) "col-resize")}}
+        (when (or (not no-data?) retain-header-on-empty?)
+          (table-utils/render-header state props this))
+        (when error
+          [:div {:style {:padding "0.5em"}}
+           (style/create-server-error-message error)])
+        (when (and (not error) no-data?)
+          (style/create-message-well (or (:empty-message props) "There are no rows to display.")))
+        [table-utils/Body
+         (assoc props
+           :columns (filter :visible? (react/call :get-ordered-columns this))
+           :rows (:display-rows @state))]]]]
+     (when-not (= (:pagination props) :none)
+       [:div {:style {:paddingTop (:paginator-space props)}}
+        [table-utils/Paginator
+         {:width (:width props)
+          :pagination-params (select-keys (:query-params @state) [:current-page :rows-per-page])
+          :num-visible-rows (:filtered-count @state)
+          :num-total-rows (or (:num-total-rows props) (:grouped-count @state))
+          :on-change #(swap! state update-in [:query-params] merge %)
+          :initial-rows-per-page (get-in @state [:query-params :rows-per-page])}]])]))
+
+(defn- refresh-table-rows [{:keys [props state refs]}]
+  (react/call :show (@refs "blocker"))
+  (let [{:keys [pagination data ->row]} props]
+    (if (fn? pagination)
+      (pagination (merge (select-keys @state [:filter-group-index]) (:query-params @state))
+                  (fn [{:keys [group-count filtered-count rows error]}]
+                    (react/call :hide (@refs "blocker"))
+                    (swap! state assoc
+                           :grouped-count group-count
+                           :filtered-count filtered-count
+                           :display-rows (map ->row rows)
+                           :no-data? (empty? rows)
+                           :error error)))
+      (let [{:keys [current-page rows-per-page sort-column sort-order filter-text]} (:query-params @state)
+            grouped-data (if-not (:filter-groups props)
+                           data
+                           (filter (:pred (get-in props [:filter-groups (:filter-group-index @state)]))
+                                   data))
+            filtered-data (if-let [txt (not-empty filter-text)]
+                            (table-utils/filter-data grouped-data ->row (:columns props) txt)
+                            grouped-data)
+            rows (map ->row filtered-data)
+            sorted-rows (if sort-column
+                          (let [column (get (:given-columns-by-header @state) sort-column)
+                                column-index (utils/first-matching-index (fn [{:keys [header]}] (= header sort-column)) (:column-meta @state))
+                                key-fn (or (:sort-by column) identity)
+                                key-fn (if (= key-fn :text) (:as-text column) key-fn)]
+                            (sort-by (fn [row] (key-fn (nth row column-index))) rows))
+                          rows)
+            ordered-rows (if (= :desc sort-order) (reverse sorted-rows) sorted-rows)
+            ;; realize this sequence so errors can be caught early:
+            clipped-rows (if (= pagination :none)
+                           ordered-rows
+                           (doall (take rows-per-page (drop (* (dec current-page) rows-per-page) ordered-rows))))]
+        (react/call :hide (@refs "blocker"))
+        (swap! state assoc
+               :grouped-count (count grouped-data)
+               :filtered-count (count filtered-data)
+               :display-rows clipped-rows
+               :no-data? (empty? clipped-rows))))))


Fix indentation issue, pass umm-lib-collection to science-keywords->facet-fields

--- indexer-app/src/cmr/indexer/data/concepts/collection.clj
+++ indexer-app/src/cmr/indexer/data/concepts/collection.clj
@@ -310,12 +310,12 @@
                             (util/string->gzip-base64
                              (pr-str
                               (into {} (for [ta tag-associations]
-                                          [(:tag-key ta) (util/remove-nil-keys)
-                                                         {:data (:data ta)}])))))}
+                                          [(:tag-key ta) (util/remove-nil-keys
+                                                          {:data (:data ta)})])))))}
            (collection-temporal-elastic context concept-id umm-spec-collection)
            (spatial/collection-orbit-parameters->elastic-docs umm-spec-collection)
            (spatial->elastic umm-spec-collection)
-           (sk/science-keywords->facet-fields umm-spec-collection)
+           (sk/science-keywords->facet-fields collection)
            (collection-humanizers-elastic context umm-spec-collection))))

 (defn- get-elastic-doc-for-tombstone-collection


Remove unused test that doesn't compile

Remove unused test that doesn't compile

--- lein-light-nrepl/test/lein_light_nrepl/core_test.clj
+++ lein-light-nrepl/test/lein_light_nrepl/core_test.clj
@@ -1,7 +0,0 @@
-(ns lein-light-nrepl.core-test
-  (:require [clojure.test :refer :all]
-            [lein-light-nrepl.core :refer :all]))
-
-(deftest a-test
-  (testing "FIXME, I fail."
-    (is (= 0 1))))


(TK-84) Change :refer to :as

(TK-84) Change :refer to :as

Use :as instead of :refer to improve readability.

--- src/puppetlabs/trapperkeeper/services/webserver/jetty9_core.clj
+++ src/puppetlabs/trapperkeeper/services/webserver/jetty9_core.clj
@@ -26,7 +26,7 @@
            (org.eclipse.jetty.util URIUtil))

   (:require [ring.util.servlet :as servlet]
-            [ring.util.codec :refer [url-decode]]
+            [ring.util.codec :as codec]
             [clojure.string :as str]
             [clojure.set :as set]
             [clojure.tools.logging :as log]
@@ -326,7 +326,7 @@
                                  (:port target)
                                  (with-leading-slash
                                    (URIUtil/addPaths (:path target) context-path))
-                                 (url-decode (str query))
+                                 (codec/url-decode (str query))
                                  nil)]
             (if-let [rewrite-uri-callback-fn (:rewrite-uri-callback-fn options)]
               (rewrite-uri-callback-fn target-uri req)


Use H1 text from current page, add last name.

--- src-cljs/frontend/components/stories.cljs
+++ src-cljs/frontend/components/stories.cljs
@@ -34,11 +34,11 @@
            [:div.hero-title.center-block
             [:div.text-center
              shopify-logo]
-            [:h1.text-center "Shopify’s CI, with Circle CI."]
+            [:h1.text-center "Scalable Continuous Integration with CircleCI"]
             [:h3.text-center
              "“We were able to rapidly grow our team and code base without fear of outgrowing CircleCI.”"
              [:br]
-             "John, Director of Engineering, Shopify"]]]]]
+             "John Duff, Director of Engineering, Shopify"]]]]]

         [:div.outer-section
          [:section.container


Removed events and errors from sensors table.

These columns should be removed from C* at some point as well as we
don't use them.

--- src-cljs/kixi/hecuba/tabs/programmes.cljs
+++ src-cljs/kixi/hecuba/tabs/programmes.cljs
@@ -567,8 +567,6 @@
             (sorting-th owner "Device ID" :device_id)
             (sorting-th owner "Location" :location)
             (sorting-th owner "Privacy" :privacy)
-            (sorting-th owner "Events" :events)
-            (sorting-th owner "Errors" :errors)
             (sorting-th owner "Earliest Event" :lower_ts)
             (sorting-th owner "Last Event" :upper_ts)
             (sorting-th owner "Status" :status)]]
@@ -577,7 +575,7 @@
                        (sort-by sort-key flattened-sensors)
                        (reverse (sort-by sort-key flattened-sensors)))]
              (let [{:keys [device_id type unit period resolution status
-                           events errors parent-device lower_ts upper_ts]} row
+                           parent-device lower_ts upper_ts]} row
                    {:keys [name privacy location]} parent-device
                    id (str type "-" device_id)]
                [:tr {:onClick (fn [_ _]
@@ -595,8 +593,6 @@
                 [:td device_id]
                 [:td location]
                 [:td privacy]
-                [:td events]
-                [:td errors]
                 [:td (str lower_ts)]
                 [:td (str upper_ts)]
                 [:td (status-label status)]]))]])))))


CMR-1711 Updates mime-types tests

CMR-1711 Updates mime-types tests

--- common-lib/test/cmr/common/test/mime_types.clj
+++ common-lib/test/cmr/common/test/mime_types.clj
@@ -4,51 +4,37 @@
             [clojure.string :as str]
             [cmr.common.mime-types :as mt]))

-(def supported-mime-types
-  "The mime-types supported by search."
-  #{"*/*"
-    "application/xml"
-    "application/json"
-    "application/echo10+xml"
-    "application/dif+xml"
-    "application/atom+xml"
-    "application/iso19115+xml"
-    "application/iso:smap+xml"
-    "text/csv"
-    "application/vnd.google-earth.kml+xml"
-    "application/opendata+json"})
-
 ;; Tests various times when the content type should be used when extracting mime types from headers
 (deftest mime-type-from-headers-test
   (testing "extract first preferred valid mime type"
-    (is (= "application/json"
+    (is (= mt/json
            (mt/mime-type-from-headers
              {"accept" "text/html, application/json;q=9"}))))

   (testing "accept header used if available"
-    (is (= "application/iso:smap+xml"
+    (is (= mt/iso-smap
            (mt/mime-type-from-headers
              {"accept" "application/iso:smap+xml"
               "content-type" "application/xml"})))

     (testing "accept parameters are ignored"
-      (is (= "application/xml"
+      (is (= mt/xml
              (mt/mime-type-from-headers
                {"accept" "application/xml; q=1"})))))

   (testing "content type used if accept not set"
-    (is (= "application/xml"
+    (is (= mt/xml
            (mt/mime-type-from-headers
              {"content-type" "application/xml"})))

     (testing "accept parameters are ignored"
-      (is (= "application/xml"
+      (is (= mt/xml
              (mt/mime-type-from-headers
                {"content-type" "application/xml; q=1"})))))

   (testing "*/* in accept header is ignored"
     (testing "use content type if not provided"
-      (is (= "application/xml"
+      (is (= mt/xml
              (mt/mime-type-from-headers
                {"accept" "*/*"
                 "content-type" "application/xml"}))))
@@ -61,17 +47,17 @@

 (deftest convert-format-extension-to-mime-type
   (testing "valid extensions"
-    (is (= "application/json" (mt/path-w-extension->mime-type "granules.json")))
-    (is (= "application/xml" (mt/path-w-extension->mime-type "granules.xml")))
-    (is (= "application/echo10+xml" (mt/path-w-extension->mime-type "granules.echo10")))
-    (is (= "application/iso:smap+xml" (mt/path-w-extension->mime-type "granules.iso-smap")))
-    (is (= "application/iso:smap+xml" (mt/path-w-extension->mime-type "granules.iso_smap")))
-    (is (= "application/iso19115+xml" (mt/path-w-extension->mime-type "granules.iso")))
-    (is (= "application/iso19115+xml" (mt/path-w-extension->mime-type "granules.iso19115")))
-    (is (= "application/dif+xml" (mt/path-w-extension->mime-type "granules.dif")))
-    (is (= "text/csv" (mt/path-w-extension->mime-type "granules.csv")))
-    (is (= "application/vnd.google-earth.kml+xml" (mt/path-w-extension->mime-type "granules.kml")))
-    (is (= "application/opendata+json" (mt/path-w-extension->mime-type "granules.opendata"))))
+    (is (= mt/json (mt/path-w-extension->mime-type "granules.json")))
+    (is (= mt/xml (mt/path-w-extension->mime-type "granules.xml")))
+    (is (= mt/echo10 (mt/path-w-extension->mime-type "granules.echo10")))
+    (is (= mt/iso-smap (mt/path-w-extension->mime-type "granules.iso-smap")))
+    (is (= mt/iso-smap (mt/path-w-extension->mime-type "granules.iso_smap")))
+    (is (= mt/iso (mt/path-w-extension->mime-type "granules.iso")))
+    (is (= mt/iso (mt/path-w-extension->mime-type "granules.iso19115")))
+    (is (= mt/dif (mt/path-w-extension->mime-type "granules.dif")))
+    (is (= mt/csv (mt/path-w-extension->mime-type "granules.csv")))
+    (is (= mt/kml (mt/path-w-extension->mime-type "granules.kml")))
+    (is (= mt/opendata (mt/path-w-extension->mime-type "granules.opendata"))))
   (testing "invalid extensions"
     (are [uri]
          (= nil (mt/path-w-extension->mime-type uri))


Generate atom-counts CSV for directory analysis

--- src/atom_finder/questions/atom_counts.clj
+++ src/atom_finder/questions/atom_counts.clj
@@ -48,3 +48,13 @@
      (reduce (partial merge-with +))
      pprint)
   )
+
+;; Generate a full CSV of the data, useful for by-module or by-directory analysis
+;; See src/analysis/directory-counts.R
+'((->> "atom-counts_2017-10-25_1.edn"
+     read-data
+     rest
+     (remove nil?)
+     (map #(assoc (:atom-counts %1) :file (:file %1)))
+     (maps-to-csv "src/analysis/data/atom-counts_2017-10-25_1.csv")
+     ))


whtsp

whtsp

--- sidecar/src/figwheel_sidecar/core.clj
+++ sidecar/src/figwheel_sidecar/core.clj
@@ -331,7 +331,7 @@
                               (.toString out))]
     (send-message! st :compile-failed
                    { :exception-data parsed-exception
-                    :formatted-exception formatted-exception })))
+                     :formatted-exception formatted-exception })))

 (defn compile-warning-occured [st msg]
   (send-message! st :compile-warning { :message msg }))


adding status line in nREPL env to hack around nREPL prompt complications

this is a pragmatic solution for reporting multiple connections in
nREPL

--- sidecar/src/figwheel_sidecar/repl.clj
+++ sidecar/src/figwheel_sidecar/repl.clj
@@ -1,7 +1,7 @@
 (ns figwheel-sidecar.repl
   (:require
    [figwheel-sidecar.cljs-utils.exception-parsing :as cljs-ex]
-   [strictly-specking-standalone.ansi-util :refer [with-color-when]]
+   [strictly-specking-standalone.ansi-util :refer [with-color-when color]]
    [cljs.repl]
    [cljs.stacktrace]
    [cljs.analyzer :as ana]
@@ -77,7 +77,7 @@
       {})))

 (defn clean-stacktrace [stack-trace]
-    (map #(update-in % [:file]
+  (map #(update-in % [:file]
                    (fn [x]
                      (when (string? x)
                        (first (string/split x #"\?")))))
@@ -163,6 +163,7 @@
           opts' (:repl-opts figwheel-env)]
       (apply cljs-repl figwheel-env (apply concat opts')))
     (catch Exception e
+      (println "!!!" (.getMessage e))
       (let [message "Failed to launch Figwheel CLJS REPL: nREPL connection found but unable to load piggieback.
 This is commonly caused by
  A) not providing piggieback as a dependency and/or
@@ -227,9 +228,24 @@
            (throw (ex-info "Hey" {})))))))

 (defn connection-count [figwheel-server build-id]
-  (when-let [res (get (server/connection-data figwheel-server)
-                      build-id)]
-    res))
+  (get (server/connection-data figwheel-server) build-id))
+
+(defn prompt-fn [figwheel-server build-id]
+  (if (in-nrepl-env?)
+    #(when-let [c (connection-count figwheel-server build-id)]
+       (when (> c 1)
+         (with-color-when (-> figwheel-server :ansi-color-output)
+           (println
+            (color
+             (str "v------- " build-id "!{:conn " c "} -------")
+             :magenta)))))
+    #(print
+      (str
+       (when build-id (str build-id ":"))
+       ana/*cljs-ns*
+       (when-let [c (connection-count figwheel-server build-id)]
+         (when (< 1 c) (str "!{:conn " c "}")))
+       "=> "))))

 (defn cljs-repl-env
   ([build figwheel-server]
@@ -237,15 +253,7 @@
   ([build figwheel-server opts]
    (let [opts (merge (assoc (or (:compiler build) (:build-options build))
                             :warn-on-undeclared true
-                            :prompt (fn []
-                                      (let [c (connection-count figwheel-server
-                                                                (:id build))]
-                                        (print (str
-                                                (when (:id build) (str (:id build) ":"))
-                                                ana/*cljs-ns*
-                                                (when (and c (< 1 c))
-                                                  (str "!{:conn " c "}"))
-                                                "=> "))))
+                            :prompt (prompt-fn figwheel-server (:id build))
                             :eval #'catch-warnings-and-exceptions-eval-cljs)
                      opts)
          figwheel-server (assoc figwheel-server


Evict cache for queue-ids when queue is empty

--- src/background/ygq/background/parser.cljs
+++ src/background/ygq/background/parser.cljs
@@ -40,7 +40,9 @@
   {:video/queue
    (fn [{:keys [::g/access-token ::cache ast] :as env}]
      (go
-       (if (get-in ast [:params :clear-cache]) (swap! cache dissoc ::queue-ids))
+       (if (and cache (or (get-in ast [:params :clear-cache])
+                          (empty? (get @cache ::queue-ids))))
+         (swap! cache dissoc ::queue-ids))
        (let [videos (<!cache cache ::queue-ids (g/youtube-queue-ids env))]
          (<! (p/read-chan-seq
                #(p/read-chan-values
@@ -61,9 +63,9 @@
         :youtube.video/by-id
         (go
           (let [video (<!cache cache key
-                               (g/youtube-details #:youtube.video{:id              id
-                                                                  :parts           (query->parts query)
-                                                                  ::g/access-token access-token}))]
+                        (g/youtube-details #:youtube.video{:id              id
+                                                           :parts           (query->parts query)
+                                                           ::g/access-token access-token}))]
             (p/continue-with-reader (assoc env ::entity video)
                                     camel-key-reader)))


make tag page helper views public, fix new-tag-view

No reason to be private; new-tag-view should return a fn with the same
parameters as the surrounding defn

--- src/braid/client/ui/views/pages/tags.cljs
+++ src/braid/client/ui/views/pages/tags.cljs
@@ -9,11 +9,11 @@
             [braid.common.util :refer [valid-tag-name?]])
   (:import [goog.events KeyCodes]))

-(defn- new-tag-view
+(defn new-tag-view
   [data]
   (let [error (r/atom nil)
         set-error! (fn [err?] (reset! error err?))]
-    (fn []
+    (fn [data]
       [:input.new-tag
        {:class (when error "error")
         :on-key-up
@@ -29,7 +29,7 @@
             (aset (.. e -target) "value" "")))
         :placeholder "New Tag"}])))

-(defn- tag-info-view
+(defn tag-info-view
   [tag]
   (let [group-id (subscribe [:open-group-id])
         admin? (subscribe [:current-user-is-group-admin?] [group-id])]


start reworking transaction processing

start reworking transaction processing

--- src/clj/clj_money/models/transactions.clj
+++ src/clj/clj_money/models/transactions.clj
@@ -280,6 +280,7 @@
                                     :transaction-date transaction-date}
                                    {:limit 1})))

+; TODO delete
 (defn- upsert-item
   "Updates the specified transaction item"
   [storage {:keys [id transaction-date] :as item}]
@@ -480,6 +481,13 @@
           (select-transaction-items s
                                     (prepare-criteria criteria)
                                     options)))))
+
+(defn find-item
+  "Returns the first item matching the specified criteria"
+  ([storage-spec criteria]
+   (find-item storage-spec criteria {}))
+  ([storage-spec criteria options]
+   (first (search-items storage-spec criteria options))))

 (defn- recalculate-account-item
   "Accepts a processing context and an item, updates
@@ -656,13 +664,6 @@
            (select-transaction-items s {:account-id account-id
                                         :reconciliation-id nil})))))

-(defn- process-item-upserts
-  "Process items in a transaction update operation"
-  [storage items]
-  (->> items
-       (map before-save-item)
-       (mapv #(upsert-item storage %))))
-
 (defn reload
   "Returns an updated copy of the transaction"
   [storage-spec {:keys [id transaction-date]}]
@@ -745,21 +746,6 @@
       current-item)
     current-item))

-(defn- process-updated-items
-  "Processes the updated items in the transaction
-  in the context and appends items to the :base-items attribute
-  with the list of items that need to be processed for
-  index and balance."
-  [{:keys [storage transaction existing-tx] :as context}]
-  (let [base-items (->> (:items transaction)
-                        (map #(as-> % i
-                                (assoc i :transaction-id (:id transaction))
-                                (before-save-item i)
-                                (upsert-item storage i)))
-                        (map #(older-item existing-tx %))
-                        (mapv #(get-previous-item storage %)))]
-    (update-in context [:base-items] #(concat % base-items))))
-
 (defn- find-existing-transaction
   "Given a transaction that has been updated, find the existing
   transaction in storage. If none can be found, throw an exception."
@@ -773,10 +759,6 @@
                  {:id id
                   :search-date search-date})))))

-(defn- assoc-existing-transaction
-  [{:keys [storage transaction] :as context}]
-  (assoc context :existing (find-existing-transaction storage transaction)))
-
 (defn- recalculate-indexes-and-balances-for-update
   [{:keys [storage base-items] :as context}]
   (doseq [item base-items]
@@ -784,11 +766,47 @@
   context)

 (defn- update-transaction*
-  [{:keys [storage transaction] :as context}]
+  [storage transaction]
   (->> transaction
        before-save
-       (update-transaction storage))
-  (assoc context :transaction (reload storage transaction)))
+       (update-transaction storage)))
+
+(defn- update-full-transaction
+  "Update the transaction and associated items."
+  [storage transaction]
+  (update-transaction* storage transaction)
+  (doseq [item (:items transaction)]
+    (as-> item i
+      (assoc i :transaction-id (:id transaction))
+      (before-save-item i)
+      (upsert-item storage i))))
+
+(defn- find-base-item
+  "Given an account ID and a date, finds the transaction item for that
+  account that immediately precents the given date"
+  [storage account-id as-of]
+  ; TODO If no item is found, we need to know if it's because
+  ; there is not item in this partition, or no item at all.
+  ; I'm not sure of the storage layer is already walking back,
+  ; but I'm guessing it is not.
+  (find-item storage
+             {:transaction-date [:< as-of]
+              :account-id account-id}
+             {:sort [[:transaction-date :desc]
+                     [:index :desc]]
+              :limit 1}))
+
+(defn- recalculate-account
+  "Recalculates statistics for items in the the specified account
+  as of the specified date"
+  [storage account-id as-of]
+  (let [base-item (find-base-item storage account-id as-of)
+        items (search-items storage
+                            {:account-id account-id
+                                     :transaction-date [:>= as-of]}
+                            {:sort [:transaction-date :index]})]
+    (pprint {:base-item base-item
+             :items items})))

 ; Processing a transaction
 ; 1. Save the transaction and item records
@@ -812,16 +830,21 @@
     (let [validated (validate storage ::existing-transaction transaction)]
       (if (validation/has-error? validated)
         validated
-        (-> {:transaction validated
-             :storage storage
-             :base-items []}
-            assoc-existing-transaction
-            process-dereferenced-items
-            process-dereferenced-accounts
-            process-updated-items
-            recalculate-indexes-and-balances-for-update
-            update-transaction*
-            :transaction)))))
+        (do
+        (let [existing (find-existing-transaction storage transaction)
+              dereferenced-items (->> (:items existing)
+                                     (remove #(some (fn [i] (= (:id i)
+                                                               (:id %)))
+                                                    (:items validated))))
+              recalc-base-date (earlier (:transaction-date existing)
+                                        (:transaction-date validated))
+              recalc-account-ids (->> (:items validated)
+                                   (concat dereferenced-items)
+                                   (map :account-id)
+                                   (into #{}))]
+              (update-full-transaction storage validated)
+              (doseq [account-id recalc-account-ids]
+                (recalculate-account storage account-id recalc-base-date))))))))

 (defn- get-preceding-items
   "Returns the items that precede each item in the


Fix ajax request type for UPDATE action.

--- src/cljs/hatnik/web/client/z_actions.cljs
+++ src/cljs/hatnik/web/client/z_actions.cljs
@@ -86,13 +86,13 @@

 (defn update-email-action [project-id action-id]
     (let [artifact (get-data-from-input "artifact-input")
-        email (get-data-from-input "emain-input")
-        email-body (get-data-from-input "emain-body-input")
-        data {:project-id project-id
-              :type "email"
-              :address email
-              :template email-body
-              :library artifact}]
+          email (get-data-from-input "emain-input")
+          email-body (get-data-from-input "emain-body-input")
+          data {:project-id project-id
+                :type "email"
+                :address email
+                :template email-body
+                :library artifact}]
     (if (or
          (= "" artifact)
          (= "" email)
@@ -102,6 +102,6 @@
       (do
         (.modal ($ :#iModal) "hide")
         (ajax
-         (str "/api/actions/" action-id) "POST"
+         (str "/api/actions/" action-id) "PUT"
          data #(update-email-action-callback data %))))))


Render 'static' html in hit-rate-chart render fn

--- src/cljs/load_test_om/hit_rate_chart.cljs
+++ src/cljs/load_test_om/hit_rate_chart.cljs
@@ -46,39 +46,12 @@
   {:x (min-max (map :x data))
    :y (min-max (map :y data))})

-(defn update-chart [el width height data]
-  (let [scales (get-scales (domain data) width height)
+(defn update-chart [el data]
+  (let [width 446
+        height 150
+        scales (get-scales (domain data) width height)
         axes   (get-axes scales)]
     (draw-points el scales axes data)))
-
-(defn create-chart [el data]
-  (let [width 446
-        height 150
-        top 20
-        right 10
-        bottom 30
-        left 30
-        svg (-> js/d3
-                (.select el)
-                (.append "svg")
-                (.attr "class" "d3")
-                (.attr "width" (+ width left right))
-                (.attr "height" (+ height top bottom))
-                (.append "g")
-                (.attr "transform" (str "translate(" left "," top ")")))]
-    (-> svg
-        (.append "g")
-        (.attr "class" "x axis")
-        (.attr "transform" (str "translate(0," height ")")))
-    (-> svg
-        (.append "g")
-        (.attr "class" "y axis")
-        (.append "text")
-        (.attr "transform" "rotate(-90)"))
-    (-> svg
-        (.append "path")
-        (.attr "class" "line"))
-    (update-chart el width height data)))

 (defn load-test->data [load-test]
   (->> (:data-points load-test)
@@ -90,8 +63,27 @@
   (reify
     om/IDidMount
     (did-mount [_]
-      (create-chart (om/get-node owner) (load-test->data load-test)))
+      (update-chart (om/get-node owner) (load-test->data load-test)))
+
+    om/IDidUpdate
+    (did-update [_ _ _]
+      (update-chart (om/get-node owner) (load-test->data load-test)))

     om/IRender
     (render [_]
-      (dom/div #js {:className "chart hit-rate-chart"}))))
+      (let [width 446
+            height 150
+            top 20
+            right 10
+            bottom 30
+            left 30]
+        (dom/div #js {:className "chart hit-rate-chart"}
+                 (dom/svg #js {:className "d3"
+                               :width (+ width left right)
+                               :height (+ height top bottom)}
+                          (dom/g #js {:transform (str "translate(" left "," top ")")}
+                                 (dom/g #js {:className "x axis"
+                                             :transform (str "translate(0, " height ")")})
+                                 (dom/g #js {:className "y axis"}
+                                        (dom/text #js {:transform "rotate(-90)"}))
+                                 (dom/path #js {:className "line"}))))))))


Reformat the final map

Reformat the final map

--- src/cljs/travel_site/components/city.cljs
+++ src/cljs/travel_site/components/city.cljs
@@ -467,7 +467,7 @@
                    [:div {:class "ui text loader"} "Loading..."]]
                   (om/build attraction-map-view [current-city journey transit-journey false])
                   [:div {:class "ui basic centered segment"
-                         :on-click #(animate-scroll-to-element (js/$. ".final-directions"))}
+                         :on-click #(animate-scroll-to-element (js/$. ".final-directions-header"))}
                    [:a {:class "ui red button"} "Final Route" ]]]]]

                ;; Adjust the width depending on whether on a computer vs a tablet/mobile device
@@ -479,12 +479,17 @@
                                                             (-> current-city :attractions :data)])]]

               ;; Display the big map
-              [:div {:class "ui fourteen wide column row basic segment final-directions"}
-               [:div {:class "fourteen wide column"}
-                [:h1 "Final Route"]
-                (om/build attraction-map-view [current-city journey transit-journey true])
+              [:div {:class "ui fourteen wide column row final-directions-header"
+                     :style {:padding-bottom 0}}
+               [:h1 "Final directions"]]
+              [:div {:class "ui fourteen wide column row basic segment final-directions"
+                     :style {:margin-top 0}
+                     }
+               [:div {:class "three wide column"}
                 (if (valid-journey? journey)
-                  (om/build attraction-map-legend-view transit-journey))]]
+                  (om/build attraction-map-legend-view transit-journey)) ]
+               [:div {:class "eleven wide column"}
+                (om/build attraction-map-view [current-city journey transit-journey false])]]

               [:div {:class "ui fourteen wide column row basic segment final-transit-directions"}
                [:div {:class "fourteen wide column"}


Solved 6.2 - Clojure way - tomorrow to check fpins variant - perhaps to decrease n if it equals Int.MaxValue

--- src/fpinscala/purely_functional_state.clj
+++ src/fpinscala/purely_functional_state.clj
@@ -33,7 +33,7 @@
 (defn non-negative-int
   "Generates random integer between 0 and Int.maxValue (inclusive)"
   [rng]
-  (let [{:keys [n nxt-rng]} (rng)]
+  (with-rng (rng) [n nxt-rng]
     (if (> n Integer/MIN_VALUE)
       (make-result (Math/abs ^int n) nxt-rng)
       (make-result Integer/MAX_VALUE nxt-rng))))
@@ -41,7 +41,16 @@
 (defn non-negative-int-fpins
   "FPINS variant of above function - haha - and I was thinking: Adding one is way too simple :)"
   [rng]
-  (let [{:keys [n nxt-rng]} (rng)]
+  (with-rng (rng) [n nxt-rng]
     (if (< n 0)
       (make-result (- (inc n)) nxt-rng)
       (make-result n nxt-rng))))
+
+;6.2
+;mine
+(defn a-double
+  "Generates Double between 0 (inclusive) and 1 (exclusive)"
+  [rng]
+  (with-rng (non-negative-int rng) [n nxt-rng]
+            (let [dbl (/ n Integer/MAX_VALUE)]
+              (make-result (double dbl) nxt-rng))))


Ok, now rng stuff is partially (not all generators) adjusted to State stuff

--- src/fpinscala/purely_functional_state.clj
+++ src/fpinscala/purely_functional_state.clj
@@ -306,24 +306,57 @@
   #(from-state (f %) :let [v s]
              ((g v) s)))

-(defn map-via-flat-map-s
-  "Generalized version of map-via-flat-map from exercise 6.9, for exercise 6.10"
-  [s f]
-  (flat-map-s s (fn [x] (unit (f x)))))
-
-(defn map2-via-flat-map-s
-  [s1 s2 f]
-  (flat-map-s s1 (fn [a] (map-via-flat-map-s s2 #(f a %)))))
-
 (defn unit-state
   "Generalized Unit function from section 6.5 of fpins"
   [a]
   (fn [rng] (make-result-state a rng)))

+(defn map-via-flat-map-s
+  "Generalized version of map-via-flat-map from exercise 6.9, for exercise 6.10"
+  [s f]
+  (flat-map-s s (fn [x] (unit-state (f x)))))
+
+(defn map2-via-flat-map-s
+  [s1 s2 f]
+  (flat-map-s s1 (fn [a] (map-via-flat-map-s s2 #(f a %)))))
+
+(defn unit-state
+  "Generalized Unit function from section 6.5 of fpins"
+  [a]
+  (fn [rng] (make-result-state a rng)))
+
 (defn state-sequence-fpins
   "sequence function for exercise 6.7 FPINS variant"
   [fs]
   (fpinscala.strictness-and-laziness/fold-right             ;Notice that this variant is using fold-right
-    (unit '())                                              ;Check out that "unit-produced" function is used as z value (now - it wouldn't be really
+    (unit-state '())                                              ;Check out that "unit-produced" function is used as z value (now - it wouldn't be really
     #(map2-via-flat-map-s % %2 (fn [a b] (cons a b)))                 ;correct to say it is "initial" but rather neutral (or terminating?) element
-    fs))+    fs))
+
+(declare simple-rng-s)
+
+(defn make-simple-rng-s
+  "Constructor fn for simple RNGs but customized to work with general state"
+  [seed]
+  (fn []
+    (simple-rng-s seed)))
+
+(defn- simple-rng-s
+  "As per listing 6.2 from FPINS"
+  [^long seed]
+  ;Type hint needed here so multiplication below does not yield int but rather long
+  (let [nseed (bit-and (+ (unchecked-multiply seed 0x5deece66d) 0xb) 0xffffffffffff)
+        ;unchecked-multiply is falling back to Java semantic of multiplication
+        ;to make this working same way as in Scala/FPINS option
+        nxt-rng (make-simple-rng-s nseed)
+        n (.intValue (unsigned-bit-shift-right nseed 16))]
+    (make-result-state n nxt-rng)))
+
+(defn non-negative-int-fpins-s
+  "FPINS variant of above function - haha - and I was thinking: Adding one is way too simple :)"
+  [rng]
+  (from-state (rng) :let [n nxt-rng]
+            (if (< n 0)
+              (make-result-state (- (inc n)) nxt-rng)
+              (make-result-state n nxt-rng))))
+


Solving 5.3 of fpins

Solving 5.3 of fpins

--- src/fpinscala/strictness_and_laziness.clj
+++ src/fpinscala/strictness_and_laziness.clj
@@ -62,5 +62,20 @@

 ;5.3
 ;mine
+(defn my-take-while [f s]
+  (letfn [(go [s acc]
+              (if (seq s)
+                (let [value (first s)]
+                  (if (f value)
+                    (recur (rest s) (conj acc value))
+                    acc))
+                acc))]
+    (go s [])))
 ;fpins
+(defn my-take-while-fpins
+  "fpins variant of take-while"                                   ;obviously - less verbose than mine and no (obvious) accumulation :)
+  [f s]
+  (let [value (first s)]
+    (when (f value)
+      (stream-cons value (my-take-while-fpins f (rest s))))))
 ;-----------------------------------------------------------------------


Solved 5.12

Solved 5.12

--- src/fpinscala/strictness_and_laziness.clj
+++ src/fpinscala/strictness_and_laziness.clj
@@ -211,7 +211,7 @@
 ;and to use elements of "tuple" (vector in Clojure's case) appropriately
 ;-----------------------------------------------------------------------

-;5.12
+;5.12 - fibs
 ;mine
 (defn fibs-via-unfold
   "Fibonacci sequence via unfold"
@@ -223,4 +223,40 @@
   "Fibonacci sequence via unfold by fpins"
   []
   (unfold-fpins [0 1] #(when-let [[f0 f1] %]
-                        [f0 [f1 (+ f0 f1)]])))+                        [f0 [f1 (+ f0 f1)]])))
+;-----------------------------------------------------------------------
+
+;5.12 - from
+;mine - I will use unfold-fpins as it is obviously better implementation
+(defn from-via-unfold
+  "From sequence via unfold"
+  [x]
+  (unfold-fpins x #(do [% (inc %)])))
+;fpins
+;well, conceptually the same, although I was wandering somewhat
+;with starting with vector [x (inc x)] what worked but with this
+;implementation destructuring (or "pattern matching" if you like) is not necessary
+
+;5.12 - constant
+;mine
+(defn constant-via-unfold
+  "Constant via unfold"
+  [x]
+  (unfold-fpins x #(do [% %])))
+;fpins
+;conceptually - the same
+
+;5.12 - ones
+;mine
+(defn ones-via-unfold
+  "Ones via unfold"
+  []
+  (unfold-fpins 1 #(do [% %])))
+;fpins
+;conceptually - the same
+;mine via mine unfold :) - THIS IS EXAMPLE HOW NOT TO DO IT :)
+(defn ones-via-mine-unfold
+  "Ones via my wrong implementation of unfold"
+  []
+  (map first (unfold [1 1] #(when-let [[x0 x1] %]
+                             [x0 x1]))))


Keys in the :requires map of ns-info are symbols.

--- src/main/clojure/clara/rules/compiler.clj
+++ src/main/clojure/clara/rules/compiler.clj
@@ -75,7 +75,7 @@
     (if (namespace sym)

       ;; Symbol qualified by a namespace, so look it up in the requires info.
-      (if-let [source-ns (get-in ns-info [:requires (namespace sym)])]
+      (if-let [source-ns (get-in ns-info [:requires (symbol (namespace sym))])]
         (symbol (name source-ns) (name sym))
         ;; Not in the requires block, so assume the qualified name is a refers and simply return the symbol.
         sym)


Add advance search and hide some inputs in badge advert

--- src/cljs/salava/extra/application/ui/application.cljs
+++ src/cljs/salava/extra/application/ui/application.cljs
@@ -293,9 +293,17 @@
      (if (not (:user-id @state))
        [:div
         [country-selector state]
-        [autocomplete state]
-        [text-field :name "Badge name" "search by badge name" state]
-        [text-field :issuer-name (t :gallery/Issuer) (t :gallery/Searchbyissuer) state]
+        [:div
+         [:a {:on-click #(reset! show-advanced-search (not @show-advanced-search))
+              :href "#"}
+          (if @show-advanced-search
+            (t :gallery/Hideadvancedsearch)
+            (t :gallery/Showadvancedsearch))]]
+        (if  @show-advanced-search
+          [:div
+           [autocomplete state]
+           [text-field :name "Badge name" "search by badge name" state]
+           [text-field :issuer-name (t :gallery/Issuer) (t :gallery/Searchbyissuer) state]])
         [:div.form-group
           [:label {:for   "input-email-notifications"
                    :class "col-md-3"}


Assoc matched rule on request.

Assoc matched rule on request.

--- src/clojure/buddy/auth/middleware.clj
+++ src/clojure/buddy/auth/middleware.clj
@@ -75,8 +75,12 @@
           allow?  (if-not (nil? match)
                     (accessrules/apply-rule request match)
                     (case policy :allow true :reject false true))]
-      (if (not allow?)
-        (if reject-handler
-          (reject-handler request)
-          (throw-notauthorized))
-        (handler request)))))
+      (let [request (if match
+                      (assoc request :access-rules-match
+                             (re-matches (:pattern match) (:uri request)))
+                      request)]
+        (if (not allow?)
+          (if reject-handler
+            (reject-handler request)
+            (throw-notauthorized))
+          (handler request))))))


Switch to when-let

Switch to when-let

--- src/github_changelog/conventional.clj
+++ src/github_changelog/conventional.clj
@@ -90,8 +90,7 @@
   (if-let [pull-id (parse-revert config pull)]
     {:revert-pull  pull-id
      :pull-request pull}
-    ;; TODO - when-let?
-    (if-let [[_ type scope subject] (re-find angular-pattern title)]
+    (when-let [[_ type scope subject] (re-find angular-pattern title)]
       {:type         type
        :scope        scope
        :subject      subject


Reverb is now the sum of wet and dry signals.

--- src/klangmeister/sound/synthesis.cljs
+++ src/klangmeister/sound/synthesis.cljs
@@ -180,7 +180,7 @@
         (doto (.createConvolver context)
           (-> .-buffer (set! buffer)))))))

-(def reverb
+(def wet
   (let [duration 5
         decay 3
         sample-rate 44100
@@ -189,3 +189,13 @@
                             (* (-> i (js/Math.random) (* 2.0) (- 1.0))
                                (Math/pow (- 1 (/ i length)) decay)))]
     (convolver logarithmic-decay)))
+
+(def reverb
+  (fn [context at duration]
+    (let [{upstream-input :input upstream-output :output} (-> (gain 1.0) (run-with context at duration))
+          {downstream-input :input downstream-output :output} (-> (gain 1.0) (run-with context at duration))
+          {wet-input :input wet-output :output} (-> wet (run-with context at duration))]
+      (-> upstream-output (.connect wet-input))
+      (-> wet-output (.connect downstream-input))
+      (-> upstream-output (.connect downstream-input))
+      (section upstream-input downstream-output))))


Atomic NEXT-POSITION.

Atomic NEXT-POSITION.

--- src/cbfg/core.cljs
+++ src/cbfg/core.cljs
@@ -136,7 +136,7 @@
   (if override
     (swap! positions #(assoc-in % [id] override))
     (swap! positions #(-> %
-                          (assoc-in [id] (get @positions 'NEXT-POSITION))
+                          (assoc-in [id] (get % 'NEXT-POSITION))
                           (update-in ['NEXT-POSITION] (fnil inc 0))))))

 (defn assign-positions [vis actx positions actx-ch-ch-infos override]