fix a small bug with new annotations framework

--- src/metabase/api/common.clj
+++ src/metabase/api/common.clj
@@ -123,12 +123,12 @@
    MESSAGE may be either a string or a pair like `[status-code message]`."
   ([test-fn symb value message-or-status+message-pair]
    {:pre [(symbol? symb)]}
-   (let [[status-code message] (if (string? message-or-status+message-pair) [400 message-or-status+message-pair]
-                                   message-or-status+message-pair)]
-     `(let [value# ~value]
-        (check (~test-fn value#)
-          [~status-code (format "Invalid value '%s' for '%s': %s" (str value#) ~symb ~message)])
-        value#)))
+   `(let [[status-code# message#] (if (string? ~message-or-status+message-pair) [400 ~message-or-status+message-pair]
+                                      ~message-or-status+message-pair)
+          value# ~value]
+      (check (~test-fn value#)
+        [status-code# (format "Invalid value '%s' for '%s': %s" (str value#) ~symb message#)])
+      value#))
   ([test-fn symb value]
    `(checkp-with ~test-fn ~symb ~value ~(str "test failed: " test-fn))))


lint fix.

lint fix.

--- src/metabase/middleware.clj
+++ src/metabase/middleware.clj
@@ -165,9 +165,9 @@
   "Base-64 encoded public key for this site's SSL certificate. Specify this to enable HTTP Public Key Pinning.
    See http://mzl.la/1EnfqBf for more information.") ; TODO - it would be nice if we could make this a proper link in the UI; consider enabling markdown parsing

-(defn- public-key-pins-header []
-  (when-let [k (ssl-certificate-public-key)]
-    {"Public-Key-Pins" (format "pin-sha256=\"base64==%s\"; max-age=31536000" k)}))
+;(defn- public-key-pins-header []
+;  (when-let [k (ssl-certificate-public-key)]
+;    {"Public-Key-Pins" (format "pin-sha256=\"base64==%s\"; max-age=31536000" k)}))

 (defn- api-security-headers [] ; don't need to include all the nonsense we include with index.html
   (merge (cache-prevention-headers)


Fix k8s controller pod process logs filter condition (#2055)

--- scheduler/src/cook/kubernetes/controller.clj
+++ scheduler/src/cook/kubernetes/controller.clj
@@ -444,7 +444,7 @@
            {:keys [synthesized-state pod] :as k8s-actual-state-dict} (get @k8s-actual-state-map pod-name)]
       ; Skip logging when process invocation is due to a scan and both Cook and Kubernetes think the pod is running
       ; We still want to log when process is invoked due to a state change
-      (when-not (and doing-scan? (= cook-expected-state :cook-expected-state/running) (= synthesized-state :pod/running))
+      (when-not (and doing-scan? (= cook-expected-state :cook-expected-state/running) (= (:state synthesized-state) :pod/running))
         (log/info "In" name "compute cluster, processing pod" pod-name ";"
                   "cook-expected:" (prepare-cook-expected-state-dict-for-logging cook-expected-state-dict) ","
                   "k8s-actual:" (prepare-k8s-actual-state-dict-for-logging k8s-actual-state-dict)))


weirdish refactoring of compare-results

weirdish refactoring of compare-results

--- src/midje/util/checkers.clj
+++ src/midje/util/checkers.clj
@@ -314,10 +314,20 @@
       midje-classification
       [::not-map (or (some #{:in-any-order} looseness) :strict-order)])))

--;; The code that works with two sequentials.
-
-(defn in-any-order--one-permutation
+;; There are some incommensurable utility behaviors
+(defn compare-one-map-permutation [midje-classification actual expected keys]
+  ;;  (prn "map-comparison" actual expected)
+  (reduce (fn [so-far key]
+            (if (and (find actual key)
+                     (extended-= (get actual key) (get expected key)))
+              (merge-with merge so-far {:actual-found {key (get actual key)}
+                                        :expected-found {key (get expected key)} })
+              so-far))
+          {:actual-found {} :expected-found {} :expected expected}
+          keys))
+
+
+(defn compare-one-seq-permutation
   "Compare actual elements to expected, which is one of perhaps many
    permutations of the original expected list. looseness is a subset of
    #{:gaps-ok :in-any-order}."
@@ -370,20 +380,35 @@
             :else
             (better-of candidate best-so-far)))))

-(defmethod compare-results [::not-map :in-any-order]
-  [midje-classification actual expected looseness]
-  (loop [expected-permutations (feasible-permutations expected)
+(defn- order-free-compare-results [expected expected-permutations try-permutation]
+  (loop [expected-permutations expected-permutations
          best-so-far (base-starting-candidate expected)]
     (if (empty? expected-permutations)
       best-so-far
-      (let [comparison (in-any-order--one-permutation midje-classification
-                                                      actual
-                                                      (first expected-permutations)
-                                                      looseness)]
+      (let [comparison (try-permutation (first expected-permutations))]
         (if (total-match? comparison)
           comparison
           (recur (rest expected-permutations)
                  (better-of comparison best-so-far)))))))
+
+(defmethod compare-results ::map [midje-classification actual expected looseness]
+  (order-free-compare-results expected
+                              (feasible-permutations (keys expected))
+                              (fn [permutation]
+                                (compare-one-map-permutation midje-classification
+                                                             actual
+                                                             expected
+                                                             permutation))))
+
+(defmethod compare-results [::not-map :in-any-order]
+  [midje-classification actual expected looseness]
+  (order-free-compare-results expected
+                              (feasible-permutations expected)
+                              (fn [permutation]
+                                (compare-one-seq-permutation midje-classification
+                                                             actual
+                                                             permutation
+                                                             looseness))))

 (defmethod compare-results [::not-map :strict-order]
   [midje-classification actual expected looseness]
@@ -491,36 +516,6 @@

  ;;
-
-
-
-;; TODO: try different combinations?
-(defn map-comparison--one-permutation [midje-classification actual expected keys]
-  ;;  (prn "map-comparison" actual expected)
-  (reduce (fn [so-far key]
-            ;; (println so-far key)
-            (if (and (find actual key)
-                     (extended-= (get actual key) (get expected key)))
-              (merge-with merge so-far {:actual-found {key (get actual key)}
-                                        :expected-found {key (get expected key)} })
-              so-far))
-          {:actual-found {} :expected-found {} :expected expected}
-          keys))
-
-(defmethod compare-results ::map [midje-classification actual expected looseness]
-  (loop [expected-permutations (feasible-permutations (keys expected))
-         best-so-far {:actual-found [], :expected-found [],
-                      :expected expected }]
-    (if (empty? expected-permutations)
-      best-so-far
-      (let [comparison (map-comparison--one-permutation midje-classification
-                                                        actual
-                                                        expected
-                                                        (first expected-permutations))]
-        (if (total-match? comparison)
-          comparison
-          (recur (rest expected-permutations)
-                 (better-of comparison best-so-far)))))))

 (defn match? [midje-classification actual expected looseness]


Fix typo.

Fix typo.

--- src/onyx/datomic/information_model.cljc
+++ src/onyx/datomic/information_model.cljc
@@ -131,22 +131,22 @@
    {:onyx.plugin.datomic/read-datoms
     {:model
      [{:task.lifecycle/name :read-datoms
-       :lifecycle/calls :onyx.plugin.datoms/read-datoms-calls}]}
+       :lifecycle/calls :onyx.plugin.datomic/read-datoms-calls}]}

     :onyx.plugin.datomic/read-index-range
     {:model
      [{:task.lifecycle/name :read-index-datoms
-       :lifecycle/calls :onyx.plugin.datoms/read-index-range-calls}]}
+       :lifecycle/calls :onyx.plugin.datomic/read-index-range-calls}]}

     :onyx.plugin.datomic/read-log
     {:model
      [{:task.lifecycle/name :read-log
-       :lifecycle/calls :onyx.plugin.datoms/read-log-calls}]}
+       :lifecycle/calls :onyx.plugin.datomic/read-log-calls}]}

     :onyx.plugin.datomic/commit-tx
     {:model
      [{:task.lifecycle/name :write-datoms
-       :lifecycle/calls :onyx.plugin.datoms/write-tx-calls}]}
+       :lifecycle/calls :onyx.plugin.datomic/write-tx-calls}]}

     :onyx.plugin.datomic/commit-bulk-tx
     {:model


Remove dependency on sablono from reagent example.

--- examples/reagent/src/reagent.cljs
+++ examples/reagent/src/reagent.cljs
@@ -1,22 +1,21 @@
 (ns examples.reagent
   (:require [reforms.core :as f :include-macros true]
             [reforms.binding.reagent]
-            [reagent.core :as reagent :refer [atom]]
-            [sablono.core :refer-macros [html]]))
+            [reagent.core :refer [atom render-component]]))

 (def app-state (atom {:name "John"}))

 (defn simple-view
   [data]
-  (html
-    (f/with-options {:form {:horizontal (:orientation-horizontal data)}}
-                    (f/panel
-                      "Hello, world"
-                      (f/form
-                        (f/text "Your name" "Type your name here" data [:name])
-                        (f/form-buttons
-                          (f/button-primary "Submit" #(js/alert (:name @data)))
-                          (f/button-default "Cancel" #(js/alert "Cancel!"))))))))
+  (f/with-options
+    {:form {:horizontal (:orientation-horizontal data)}}
+    (f/panel
+      "Hello, world"
+      (f/form
+        (f/text "Your name" "Type your name here" data [:name])
+        (f/form-buttons
+          (f/button-primary "Submit" #(js/alert (:name @data)))
+          (f/button-default "Cancel" #(js/alert "Cancel!")))))))

 (defn inspector-view
   [app-state]
@@ -28,7 +27,7 @@
    [simple-view app-state]
    [inspector-view app-state]])

-(reagent/render-component
+(render-component
   [main-view]
   (. js/document (getElementById "app")))


simplify

simplify

--- src/cljs/just_married/home/payment_views.cljs
+++ src/cljs/just_married/home/payment_views.cljs
@@ -9,13 +9,11 @@

 ;; should the wish list url be directly here or injected in some other way?
 (defn amazon-wish-list
-  ;; does it need to subscribe to anything here?
-  ;; maybe extract the user name or something like that?
+  "Amazon wish list view"
   []
-  "Amazon wish list view"
-  (fn []
-    [:div {:class "amazon-wish-list"}
-     [:a {:href "http://amzn.eu/hzWt6gk"} "Amazon wish list"]]))
+  [:div {:class "amazon-wish-list"}
+   [:h3 "Amazon Wish list"]
+   [:a {:href "http://amzn.eu/hzWt6gk"} "Amazon wish list"]])

 (defn stripe-form
   [language]


Added matrix-type to block.

Added matrix-type to block.

--- src/clojure/uncomplicate/neanderthal/core.clj
+++ src/clojure/uncomplicate/neanderthal/core.clj
@@ -216,6 +216,11 @@
   "Tests if x is a matrix of any kind."
   [x]
   (instance? Matrix x))
+
+(defn matrix-type
+  "Returns the type of the matrix implementation represented by keyword (:ge, :tr, :sy, etc.)."
+  [^MatrixImplementation a]
+  (.matrixType a))

 (defn ge
   "Creates a dense matrix (GE) in the context of `factory`, with `m` rows and `n` columns.


HACK to keep Pivot going - keys coming out of query are now compound, but pivot-map is single keyed...

--- src/main/clojure/org/dada/core/PivotModel.clj
+++ src/main/clojure/org/dada/core/PivotModel.clj
@@ -66,12 +66,9 @@

 	 pivot-fn (fn [old-pivotted key src-value] ;e.g. [["Sei Whale" Mon ... 20 ...] Mon [Mon 21]]
 		      (let [src-value-value (.get src-value-getter src-value) ;; e.g. 20
-			    dummy (println "PIVOT-FN:" key src-value-value old-pivotted)
 			    pivot-fns (pivot-map key)
 			    pivot-values (map #(% src-value-value old-pivotted) pivot-fns)
-			    dummy (println "PIVOT-VALUES:" pivot-values)
 			    new-pivotted (.create pivot-creator (into-array Object pivot-values))]
-			;;(println "PIVOT-FN:" key)
 			new-pivotted))

 	 unpivot-fn (fn [old-pivotted key]
@@ -83,7 +80,7 @@
 	 process-addition
 	 (fn [[extant extinct pivotted i a d] #^Update addition]
 	     (let [new (.getNewValue addition)
-		   key (key-fn new)
+		   key (last (key-fn new)) ;TODO - last is a hack - pivot-map keyed differently from data
 		   current (extant key)]
 	       (if (nil? current)
 		 ;; insertion...
@@ -117,7 +114,7 @@
 	 process-deletion
 	 (fn [[extant extinct pivotted i a d] #^Update deletion]
 	     (let [new (.getNewValue deletion)
-		   key (key-fn new)
+		   key (last (key-fn new))
 		   current (extant key)]
 	       (if (nil? current)
 		 (let [removed (extinct key)]


(PDB-4676) Update reports-partitioning migration to guard against OOM errors

Prior to this commit the reports-partitioning migration could possibly OOM
if the 500 reports it was pulling in per batch were too large. This commit
turns the FetchSize used in JDBC down to 1 and eliminates batching in the
migration. All reports are now processed serially and only one should be
held in memory at a time.

This change was tested on n2 against the SLV load test dataset which has
~345,000 reports, with the largest report rows being ~45kb in postgres.
With the change the migration was able to complete using a 256MB heap where
it previously would OOM. There seems to be a slight drop in performance,
but it appears to be less than a 10% difference across multiple runs
against this dataset.

--- src/puppetlabs/puppetdb/scf/migrate.clj
+++ src/puppetlabs/puppetdb/scf/migrate.clj
@@ -1776,12 +1776,8 @@
    "DROP TABLE resource_events_premigrate"
    "DROP FUNCTION find_resource_events_unique_dates()")))

-(defn reports-partitioning
-  ([]
-   (reports-partitioning 500))
-  ([batch-size]
-
-   (jdbc/do-commands
+(defn reports-partitioning []
+  (jdbc/do-commands
      ;; detach the sequence so it isn't modified during the migration
      "ALTER SEQUENCE reports_id_seq OWNED BY NONE"

@@ -1883,6 +1879,9 @@
                                  order by receive_time asc )
            from reports_premigrate) as sub
          where row_number = 1"]
+       ;; set the FetchSize used by jdbc to avoid any potential OOM errors caused
+       ;; by fetching too many large reports at once
+       {:fetch-size 1}
        (fn [rows]
          (let [old-cols [:id :transaction_uuid :certname :puppet_version :report_format
                          :configuration_version :start_time :end_time :receive_time :noop
@@ -1893,24 +1892,21 @@
                update-row (apply juxt (comp sutils/munge-hash-for-storage
                                             hash/report-identity-hash)
                                  old-cols)
-               insert->hash (fn [batch]
-                              (swap! reports-migrated + (count batch))
-                              (let [batch (map update-row batch)]
-                                (when (seq batch)
-                                  (doseq [g (group-by (fn [o] (-> (get o 15) ;; producer_timestamp
-                                                                  (partitioning/to-zoned-date-time)
-                                                                  (partitioning/date-suffix))) batch)]
-                                    (jdbc/insert-multi! (str "reports_" (first g))
-                                                        new-cols
-                                                        (last g)))) )
-
+               insert->hash (fn [row]
+                              (swap! reports-migrated inc)
+                              (let [updated-row (update-row row)
+                                    table-name (str "reports_" (-> updated-row
+                                                                   (get 15) ;; producer_timestamp
+                                                                   (partitioning/to-zoned-date-time)
+                                                                   (partitioning/date-suffix)))]
+                                (jdbc/insert! table-name new-cols updated-row))
                               (let [now (.getTime (java.util.Date.))]
                                 (when (> (- now @last-logged) 60000)
                                   (maplog :info
                                           {:migration 74 :at @reports-migrated :of event-count}
                                           #(trs "Migrated {0} of {1} reports" (:at %) (:of %)))
                                   (reset! last-logged now))))]
-           (dorun (map insert->hash (partition batch-size batch-size [] rows)))))))
+           (run! insert->hash rows)))))

    ;; migrate data

@@ -1948,7 +1944,7 @@
       "  ADD CONSTRAINT reports_status_fkey FOREIGN KEY (status_id) REFERENCES report_statuses(id) ON DELETE CASCADE"]

      "DROP TABLE reports_premigrate"
-     "DROP FUNCTION find_reports_unique_dates()")))
+     "DROP FUNCTION find_reports_unique_dates()"))

 (def migrations
   "The available migrations, as a map from migration version to migration function."


Implement type-editor with select-editor-builder.

--- sonic-jam/src/sonic_jam/core.cljs
+++ sonic-jam/src/sonic_jam/core.cljs
@@ -44,10 +44,14 @@
 (defonce app-state (atom {:grids {}
                           :samples []
                           :synths []
+                          :types ["synth" "sample" "grid"]
                           :grid-types ["synth" "sample"]
                           :errors []
                           :console []
                           :beat-cursors []}))
+
+(defn types []
+  (om/ref-cursor (:types (om/root-cursor app-state))))

 (defn grids []
   (om/ref-cursor (:grids (om/root-cursor app-state))))
@@ -267,86 +271,52 @@
 (def sample-param-editor
   (param-editor-builder "sample-params"))

-(defn type-editor [{:keys [cursor id set-state-ch]} owner]
-  (reify
-    om/IInitState
-    (init-state [_]
-      {:state (if (= "none" (get cursor "type"))
-                :selecting
-                :immutable)
-       :type (get cursor "type")})
-    om/IRenderState
-    (render-state [this state]
-      (condp = (:state state)
-        :selecting (dom/select #js {:value (:type state)
-                                    :onChange #(handle-change % owner state :type)
-                                    :onClick #(handle-change % owner state :type)
-                                    :style #js {:color (:link theme)}
-                                    :onKeyDown #(when (= 13 (.-which %))
-                                                  (om/update-state! owner (fn [s] (merge s {:state :immutable})))
-                                                  (condp = (:type state)
-                                                    "synth"
-                                                    (om/transact! cursor (fn [c] (assoc c
-                                                                                "type" (:type state)
-                                                                                "synth-params" {})))
-                                                    "sample"
-                                                    (om/transact! cursor (fn [c] (assoc c
-                                                                                "type" (:type state)
-                                                                                "sample-params" {})))
-                                                    "grid"
-                                                    (let [grid-id (new-id)
-                                                          grid {"name" ""
-                                                                "id" grid-id
-                                                                "bpc" 1
-                                                                "tracks" []}]
-                                                      (om/transact! cursor (fn [c] (assoc c
-                                                                                "type" (:type state)
-                                                                                "synth-params" {}
-                                                                                "sample-params" {}
-                                                                                "grid-id" grid-id)))
-                                                      (om/transact! (om/observe owner (grids))
-                                                                    (fn [c] (assoc c (get grid "id") grid)))
-                                                      (go (>! set-state-ch grid-id))))
-                                                  (go (>! set-state-ch id)))}
-                               (dom/option nil "synth")
-                               (dom/option nil "sample")
-                               (dom/option nil "grid"))
-        :immutable (dom/span nil (get cursor "type"))))))
-
-(defn select-editor-builder [key options-ref]
-  (fn [{:keys [cursor id set-state-ch]} owner]
-    (let [decorate #(let [state (om/get-state owner)]
-                      (when-not (and (= :init (:state state))
-                                     (contains? cursor key))
-                        (let [select (Select. nil nil (.getInstance FlatMenuButtonRenderer))
-                              element (gdom/getElement (om/get-state owner :id))]
-                          (.decorate select element)
-                          (gevents/listenOnce select Component.EventType.ACTION
-                                              (fn [e] (let [value (.getValue e.target)]
-                                                        (om/update-state! owner (fn [s] (merge s {:state :init})))
-                                                        (om/transact! cursor (fn [c] (assoc c key value)))
-                                                        (go (>! set-state-ch id))))))))]
-      (reify
-        om/IInitState
-        (init-state [_]
-          {:state :init
-           :id (new-id)})
-        om/IDidMount
-        (did-mount [_] (decorate))
-        om/IDidUpdate
-        (did-update [_ _ _] (decorate))
-        om/IRenderState
-        (render-state [_ state]
-          (if (and (= :init (:state state))
-                   (contains? cursor key))
-            (dom/span #js {:onClick #(om/update-state! owner (fn [s] (merge s {:state :selecting})))
-                           :style #js {:color (:link theme)}}
-                      (get cursor key))
-            (dom/div #js {:id (om/get-state owner :id)
-                          :className "goog-flat-menu-button"}
-                     "Make your choice ..."
-                     (apply dom/ul #js {:className "goog-menu"}
-                            (map #(dom/li #js {:className "goog-menuitem"} %) (om/observe owner (options-ref)))))))))))
+(defn select-editor-builder
+  ([key options-ref]
+   (let [default-commit-fn (fn [{:keys [cursor id set-state-ch key value]}]
+                             (om/transact! cursor #(assoc % key value))
+                             (go (>! set-state-ch id)))]
+     (select-editor-builder key options-ref default-commit-fn)))
+  ([key options-ref commit-fn]
+   (fn [{:keys [cursor id set-state-ch]} owner]
+     (let [listen #(let [state (om/get-state owner)]
+                     (when-not (and (= :init (:state state))
+                                    (contains? cursor key)
+                                    (not (= "none" (get cursor key))))
+                       (let [select (Select. nil nil (.getInstance FlatMenuButtonRenderer))
+                             element (gdom/getElement (om/get-state owner :id))]
+                         (.decorate select element)
+                         (gevents/listenOnce select Component.EventType.ACTION
+                                             (fn [e] (let [value (.getValue e.target)]
+                                                       (om/update-state! owner (fn [s] (merge s {:state :init})))
+                                                       (commit-fn {:key key
+                                                                   :value value
+                                                                   :cursor cursor
+                                                                   :id id
+                                                                   :set-state-ch set-state-ch
+                                                                   :owner owner})))))))]
+       (reify
+         om/IInitState
+         (init-state [_]
+           {:state :init
+            :id (new-id)})
+         om/IDidMount
+         (did-mount [_] (listen))
+         om/IDidUpdate
+         (did-update [_ _ _] (listen))
+         om/IRenderState
+         (render-state [_ state]
+           (if (and (= :init (:state state))
+                    (contains? cursor key)
+                    (not (= "none" (get cursor key))))
+             (dom/span #js {:onClick #(om/update-state! owner (fn [s] (merge s {:state :selecting})))
+                            :style #js {:color (:link theme)}}
+                       (get cursor key))
+             (dom/div #js {:id (om/get-state owner :id)
+                           :className "goog-flat-menu-button"}
+                      (str "Choose a " key)
+                      (apply dom/ul #js {:className "goog-menu"}
+                             (map #(dom/li #js {:className "goog-menuitem"} %) (om/observe owner (options-ref))))))))))))

 (def grid-type-editor
   (select-editor-builder "grid-type" grid-types))
@@ -356,6 +326,29 @@

 (def sample-editor
   (select-editor-builder "sample" samples))
+
+(def type-editor
+  (select-editor-builder "type" types
+                         (fn [{:keys [cursor id set-state-ch key value owner]}]
+                           (condp = value
+                             "grid"
+                             (let [grid-id (new-id)
+                                   grid {"name" ""
+                                         "id" grid-id
+                                         "bpc" 1
+                                         "tracks" []}]
+                               (om/transact! cursor (fn [c] (assoc c
+                                                                   "type" value
+                                                                   "synth-params" {}
+                                                                   "sample-params" {}
+                                                                   "grid-id" grid-id)))
+                               (om/transact! (om/observe owner (grids))
+                                             (fn [c] (assoc c (get grid "id") grid)))
+                               (go (>! set-state-ch grid-id)))
+                             (om/transact! cursor (fn [c] (assoc c
+                                                                 "type" value
+                                                                 "synth-params" {}))))
+                           (go (>! set-state-ch id)))))

 (defn fx-editor [{:keys [cursor id set-state-ch]} owner]
   (reify


Expose :max-redelivery-delay [IMMUTANT-426]

--- modules/messaging/src/main/clojure/immutant/messaging/hornetq.clj
+++ modules/messaging/src/main/clojure/immutant/messaging/hornetq.clj
@@ -116,9 +116,9 @@

 (defn ^{:valid-options
         #{:address-full-message-policy :dead-letter-address :expiry-address
-          :expiry-delay :last-value-queue :max-delivery-attempts :max-size-bytes
-          :page-cache-max-size :page-size-bytes :redelivery-delay :redelivery-multiplier
-          :redistribution-delay :send-to-dla-on-no-route}}
+          :expiry-delay :last-value-queue :max-delivery-attempts :max-redelivery-delay
+          :max-size-bytes :page-cache-max-size :page-size-bytes :redelivery-delay
+          :redelivery-multiplier :redistribution-delay :send-to-dla-on-no-route}}
   set-address-options
   "Sets the HornetQ-specific address options for the given match.
    This provides programatic access to options that are normally set
@@ -164,6 +164,9 @@
      is set, the message will be delivered there, or removed otherwise. See
      http://docs.jboss.org/hornetq/2.3.0.Final/docs/user-manual/html/undelivered-messages.html#undelivered-messages.configuring

+   * :max-redelivery-delay [:redelivery-delay] - Specifies the maximum
+     redelivery delay (in ms) when a :redelivery-multiplier is used.
+
    * :max-size-bytes [20971520 (20MB)] - The maximum size (in bytes) of retained messages
      on an address before :address-full-message-policy is applied. See
      http://docs.jboss.org/hornetq/2.3.0.Final/docs/user-manual/html/paging.html
@@ -182,7 +185,8 @@

    * :redelivery-multiplier [1.0] - Controls the backoff for redeliveries. The
      delay between redelivery attempts is calculated as
-     :redelivery-delay * (:redelivery-multiplier ^ attempt-count)
+     :redelivery-delay * (:redelivery-multiplier ^ attempt-count). This won't have
+     any effect if you don't also set :redelivery-delay and :max-redelivery-delay.

    * :redistribution-delay [1000] - Specifies the delay (in ms) to wait before
      redistributing messages from a node in a cluster to other nodes when the


find files using serial port

find files using serial port

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@9132 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- buildscripts/buildcheck/src/buildcheck/core.clj
+++ buildscripts/buildcheck/src/buildcheck/core.clj
@@ -7,7 +7,7 @@
   (:require [clojure.xml])
   (:gen-class))

-(def micromanager (file* "../.."))
+(def micromanager (file* "../../.."))

 (def MS-PER-HOUR (* 60 60 1000))

@@ -89,10 +89,27 @@

 (def non-windows-device-adapters #{"dc1394" "SimpleCam" "Video4Linux"})

+(defn device-adapter-dirs []
+  (filter #(and (.isDirectory %)
+                (not (.. % getName (startsWith "."))))
+          (mapcat #(.listFiles %) device-adapter-parent-dirs)))
+
+(defn files-of-type [parent-dirs suffix]
+  (let [ending (str "." suffix)]
+    (filter #(.. % getName (endsWith ending))
+            (mapcat file-seq parent-dirs))))
+
+(defn uses-serial-port [file]
+  (.contains (slurp file) "g_Keyword_Port"))
+
+(defn files-using-serial-port []
+       (seq
+         (into (sorted-set)
+               (map #(.split (.getName %) "\\.")
+                    (filter uses-serial-port (files-of-type device-adapter-parent-dirs "cpp"))))))
+
 (defn missing-vcproj []
-  (let [device-adapter-dirs (filter #(and (.isDirectory %)
-                                          (not (.. % getName (startsWith "."))))
-                                    (mapcat #(.listFiles %) device-adapter-parent-dirs))
+  (let [device-adapter-dirs (device-adapter-dirs)
         directories-without-vcproj
         (filter identity
                 (for [device-adapter-dir device-adapter-dirs]


fixing error handling

fixing error handling

--- internal/machina/src/samsara/machina/core.clj
+++ internal/machina/src/samsara/machina/core.clj
@@ -103,7 +103,8 @@
         (catch Exception x
           (as-> sm $
             (assoc $ :error {:from-state state :error x})
-            (assoc $ :state (on-failure $)))))
+            (assoc $ :state (on-failure $))
+            (dissoc $ :error))))
       (assoc sm :error {:from-state state
                         :error :machina/bad-state}))))

@@ -126,6 +127,11 @@
 ;;                                                                            ;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

+(defn do! [f]
+  (fn [v]
+    (f v)
+    v))
+
 (def sm
   {:state :machina/start
    :data   nil
@@ -135,25 +141,27 @@
                     :on-failure (constantly :machina/stop)}

-    :sleep {:fn*        (fn [_] (Thread/sleep 1000))
+    :sleep {:fn*        (do! (fn [_] (Thread/sleep 1000)))
             :on-success (constantly :write-to-file)
             :on-failure (constantly :sleep)}

-    :write-to-file {:fn*        (fn [f]
-                                  (spit f
-                                        (str (java.util.Date.))
-                                        :append true))
+    :write-to-file {:fn*        (do! (fn [f]
+                                       (println "write?")
+                                       (spit f
+                                             (str (java.util.Date.) \newline)
+                                             :append true)))

-                    :on-success (constantly :sleep)
-                    :on-failure (constantly :sleep)}}})
+                    :on-success (fn [sm] (println "OK")   (clojure.pprint/pprint sm) :sleep)
+                    :on-failure (fn [sm] (println "FAIL") (clojure.pprint/pprint sm) :sleep)}}})

 (comment

   (-> sm
       play
-      play)
+      play
+      )

   (->> sm
        (iterate play)


4clojure:: impl a func that generate a lazy sequences forming the pascal-trapezoid

--- src/clojure_learning/4clojure-exercises.clj
+++ src/clojure_learning/4clojure-exercises.clj
@@ -1982,3 +1982,68 @@
 (take 40 (iterate #(+ % 5) 5)) ;; 5 10 15...105 110
 (apply min [1 2 3]) ;; 1
 (min 1 2 3) ;; 1
+
+;; using euclid algorithm:
+(defn gcd [a b]
+  (if (zero? b) a
+    (gcd b (rem a b))))
+;; for any a>=b
+(gcd 8 5) ;; 1
+(gcd 121 11) ;; 11
+(gcd 72 27) ;; 9
+;; 8 5 -> 5 3 -> 3 2 -> 2 1 -> 1 0 -> 0 1 -> 1
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Pascal's Trapezoid
+;; Difficulty:	Easy
+;; Topics:	seqs
+;; Write a function that, for any given input vector of numbers, returns an infinite lazy sequence
+;; of vectors, where each next one is constructed from the previous following the rules used in
+;; Pascal's Triangle. For example, for [3 1 2], the next row is [3 4 3 2].
+;; (= (take 5 (__ [1]))       [[1] [1 1] [1 2 1] [1 3 3 1] [1 4 6 4 1]])
+;; (= (take 2 (__ [3 1 2]))   [[3 1 2] [3 4 3 2]])
+
+;; some warm-up :)
+(defn iterate-lazy [start]
+  (lazy-seq
+     (cons start (iterate-lazy (inc start)))))
+
+;; demo of the iterate-lazy func:
+(take 2 (iterate-lazy 1)) ;; (1 2)
+
+;; real-impl:
+(defn lazy-pascal [xs]
+  (letfn [(new-row-recur
+            [[head secnd & tail]]
+            (if (nil? secnd)
+              (list)
+              (conj (new-row-recur (cons secnd tail)) (+' head secnd))))] ;; don't loose the secnd!
+    (lazy-seq
+       (cons xs (lazy-pascal (concat [(first xs)] (new-row-recur xs) [(last xs)]))))))
+
+;; demo
+(take 2 (lazy-pascal [3 1 2]))
+(take 5 (lazy-pascal [1]))
+
+;; extracting for quicker feedback in the repl:
+(defn new-row [[head secnd & tail]]
+    (if (nil? secnd)
+      (list)
+      (conj (new-row (cons secnd tail)) (+ head secnd))))
+(new-row [3 4 3 2]) ;; (7 7 5)
+(new-row [3 1 2])   ;; (4 3)
+
+;; IMPORTANT: on Arithmetic operations
+;; Beware of arithmetic overflow! In clojure (since version 1.3 in 2011), if you use an
+;; arithmetic operator like [+] and the result is too large to fit into a 64-bit integer,
+;; an exception is thrown.
+;; You can use +' to indicate that you would rather overflow into Clojure's slower, arbitrary-precision bigint.
+
+;; case study on this exercise. reading others solutions:
+;; (fn [v0] (iterate (fn [v] (mapv +' (conj v 0) (cons 0 v))) v0))
+(doc mapv)
+;; or:
+(partial iterate
+           (fn [nums]
+             (vec (map +' (conj nums 0) (cons 0 nums)))))
+


make apply-at apply a little earlier than before to reduce the chance of lates

--- src/overtone/time_utils.clj
+++ src/overtone/time_utils.clj
@@ -70,7 +70,7 @@
 ; the instance of the function defined earlier.
 ; (apply-at #'my-melody (+ dur (now)) arg1 arg2)

-(def *APPLY-AHEAD* 50)
+(def *APPLY-AHEAD* 150)

 (defn apply-at [func ms-time & args]
   (let [delay-time (- ms-time *APPLY-AHEAD* (now))]


Fix indirect types related to ident

Fix indirect types related to ident

--- src/com/wsscode/pathom/connect/graphql.cljc
+++ src/com/wsscode/pathom/connect/graphql.cljc
@@ -83,8 +83,13 @@
       (let [[entity field] (first (vals fields))]
         (assoc root-field ::entity-field (entity-field-key prefix entity field))))))

+(defn ident-map-entry [prefix item]
+  (cond
+    (keyword? item) item
+    (vector? item) (entity-field-key prefix (first item) (second item))))
+
 (defn ident-map-params->io [{::keys [prefix]} params]
-  (->> params vals (into #{} (map (fn [[entity field]] (entity-field-key prefix entity field))))))
+  (->> params vals (into #{} (map (fn [item] (ident-map-entry prefix item))))))

 (defn index-schema-io [{::keys [prefix schema ident-map] :as input}]
   (let [schema (:__schema schema)]
@@ -96,19 +101,19 @@
                                           (type->field-entry prefix (:type %))))
                          (->> schema :queryType :fields)))
         (as-> <>
-          (reduce (fn [idx {:keys [type name]}]
+          (reduce (fn [idx {:keys [name type]}]
                     (let [params    (get ident-map name)
                           input-set (ident-map-params->io input params)]
-                      (update idx input-set pc/merge-io {(type-key prefix (:name type)) {}})))
+                      (update idx input-set pc/merge-io {(ffirst (type->field-entry prefix type)) {}})))
                   <>
                   (->> schema :queryType :fields
                        (filter (comp ident-map :name))))))))

 (defn args-translate [{::keys [prefix ident-map]} args]
   (or
-    (if-let [[entity field] (get ident-map (-> args first :name))]
+    (if-let [item (get ident-map (-> args first :name))]
       (if (= 1 (count args))
-        #{(keyword (entity-field-key prefix entity field))}))
+        #{(keyword (ident-map-entry prefix item))}))
     #{}))

 (defn index-schema-oir [{::keys    [prefix schema resolver ident-map]
@@ -125,7 +130,7 @@
                 (mapcat (fn [{:keys [type name]}]
                           (let [params    (get ident-map name)
                                 input-set (ident-map-params->io input params)
-                                fields    (-> (get index-io #{(type-key prefix (:name type))}) keys)]
+                                fields    (-> (get index-io #{(ffirst (type->field-entry prefix type))}) keys)]
                             (mapv (fn [field]
                                     [field {input-set #{resolver}}])
                               fields)))))
@@ -140,7 +145,7 @@

 (defn index-idents [{::keys [prefix ident-map]}]
   (into #{}
-        (map #(apply entity-field-key prefix %))
+        (map #(ident-map-entry prefix %))
         (->> (vals ident-map)
              (filterv #(= 1 (count %)))
              (map vals)
@@ -152,12 +157,12 @@
         fields (-> schema :queryType :fields)
         idents (filter (comp ident-map :name) fields)]
     (-> {}
-        (into (mapcat (fn [{:keys [type name]}]
+        (into (mapcat (fn [{:keys [name type]}]
                         (let [params        (get ident-map name)
                               ident-key     (keyword (kebab-case name) (kebab-case (str/join "-and-" (keys params))))
-                              entity-fields (mapv (fn [[entity attr]] (entity-field-key prefix entity attr)) (vals params))
+                              entity-fields (mapv (fn [item] (ident-map-entry prefix item)) (vals params))
                               entity-field  (cond-> entity-fields (= 1 (count entity-fields)) first)
-                              fields        (-> (get index-io #{(type-key prefix (:name type))})
+                              fields        (-> (get index-io #{(ffirst (type->field-entry prefix type))})
                                                 keys)]
                           (mapv (fn [field]
                                   [field {::entity-field entity-field


Ensure branch to merge has a symbol

Ensure branch to merge has a symbol

--- src/com/wsscode/pathom/connect/planner.cljc
+++ src/com/wsscode/pathom/connect/planner.cljc
@@ -188,8 +188,9 @@
    {::keys [node-id]}]
   (let [node     (get-in graph [::nodes node-id])
         node-sym (pc-sym node)]
-    (some #(if (= node-sym (get-in graph [::nodes % pc-sym])) %)
-      (get-in graph [::nodes root branch-type]))))
+    (if node-sym
+      (some #(if (= node-sym (get-in graph [::nodes % pc-sym])) %)
+        (get-in graph [::nodes root branch-type])))))

 (defn simplify-branch
   "If you pass a branch node with a single branch item, it removes the branch node


Fix bug

Fix bug

--- src/pinpointer/printer.cljc
+++ src/pinpointer/printer.cljc
@@ -41,7 +41,7 @@
       (print-simple-map m pr))))

 (defn- print-set [s]
-  (print-sequential "#{" pr \} (seq s)))
+  (print-sequential "#{" pr \space \} (seq s)))

 (defn- print-record [r]
   (print \#)


debugging presence...

debugging presence...

--- src/plasma/net/presence.clj
+++ src/plasma/net/presence.clj
@@ -17,7 +17,7 @@
            p-chan (filter* (fn [msg]
                              (and (associative? msg)
                                   (= :presence (:type msg))))
-                           msg-chan)]
+                           (map* :message msg-chan))]
        (dosync (alter listeners* assoc port p-chan))
        p-chan))))


Use java.io to read file instead slurp

Use java.io to read file instead slurp

slurp will decode file, thus it make the bin data not correctly.

Signed-off-by: Yen-Chin Lee <082d453d72dce940e12089a4ad48b97cfe1f3ec4@gmail.com>

--- src/emulator_4917/core.cljc
+++ src/emulator_4917/core.cljc
@@ -136,8 +136,8 @@
 (defn to-4bit-array
   "Convert 0xf4 to [f 4]"
   [s]
-  (let [h (bit-shift-right s 4) ;; 0xf4 >> 4   => f
-        l (bit-and s 0x0f)]     ;; 0xf4 & 0x0f => 4
+  (let [h (bit-and (bit-shift-right s 4) 0x0f) ;; 0xf4 >> 4   => f
+        l (bit-and s 0x0f)]                    ;; 0xf4 & 0x0f => 4
     [h l]))

 (defn parse-rom
@@ -146,7 +146,9 @@
   (flatten
    (map to-4bit-array
         #?(:clj
-           (.getBytes (slurp file) "ascii")
+           (with-open [out (java.io.ByteArrayOutputStream.)]
+             (clojure.java.io/copy (clojure.java.io/input-stream file) out)
+             (.toByteArray out))
            :cljs
            (->  (nodejs/require "fs")
                 (.readFileSync file "ascii")


permit empty where and order-by clauses

permit empty where and order-by clauses

--- src/er_cassandra/record.clj
+++ src/er_cassandra/record.clj
@@ -31,8 +31,7 @@
    (s/one s/Any :where-val)])

 (s/defschema WhereSchema
-  [(s/one WhereClauseSchema :first-where-clause)
-   WhereClauseSchema])
+  [WhereClauseSchema])

 (s/defschema ColumnsSchema
   [(s/one s/Keyword :first-col) s/Keyword])
@@ -42,8 +41,7 @@
    (s/one (s/enum :asc :desc) :order-by-dir)])

 (s/defschema OrderBySchema
-  [(s/one OrderByClauseSchema :first-order-by-clause)
-   OrderByClauseSchema])
+  [OrderByClauseSchema])

 (s/defschema LimitSchema s/Int)


Provide system message when no event is being shown

--- src/day8/re_frame/trace/view/container.cljs
+++ src/day8/re_frame/trace/view/container.cljs
@@ -85,9 +85,12 @@
    [right-hand-buttons external-window?]])

 (defn standard-header [external-window?]
-  (let [current-event @(rf/subscribe [:epochs/current-event])
+  (let [current-event           @(rf/subscribe [:epochs/current-event])
         older-epochs-available? @(rf/subscribe [:epochs/older-epochs-available?])
-        newer-epochs-available? @(rf/subscribe [:epochs/newer-epochs-available?])]
+        newer-epochs-available? @(rf/subscribe [:epochs/newer-epochs-available?])
+        event-str               (if (some? current-event)
+                                  (subs (prn-str current-event) 0 400)
+                                  "No event")]
     [[rc/h-box
       :align    :center
       :size     "auto"
@@ -100,8 +103,9 @@
                   :style    {:max-height       "42px" ;42 is exactly 2 lines which is perhaps neater than common/gs-50s (which would allow 3 lines to be seen)
                              :overflow-x       "hidden"
                              :overflow-y       "auto"
-                             :background-color "white"}
-                  :children [[:span.event-header (subs (prn-str current-event) 0 400)]]]
+                             :background-color "white"
+                             :font-style       (if (some? current-event) "normal" "italic")}
+                  :children [[:span.event-header event-str]]]
                  [:span.arrow (if newer-epochs-available?
                                 {:on-click #(rf/dispatch [:epochs/next-epoch])}
                                 {:class "arrow__disabled"})


Minor code changing on test/user ns.

Minor code changing on test/user ns.

--- test/user.clj
+++ test/user.clj
@@ -1,19 +1,31 @@
 (ns user
   (:require [clojure.tools.namespace.repl :as r]
-            [criterium.core :refer [quick-bench with-progress-reporting]]
+            [criterium.core :refer [quick-bench bench with-progress-reporting]]
             [clojure.walk :refer [macroexpand-all]]
             [clojure.pprint :refer [pprint]]
             [clojure.test :as test]
             [promesa.core :as p]
-            [promesa.protocols :as pt]))
+            [promesa.protocols :as pt]
+            [promesa.util :as pu])
+  (:import java.util.concurrent.CompletableFuture
+           java.util.concurrent.CompletionStage
+           java.util.function.Function))

-(defmacro bench
+(defmacro run-quick-bench
   [& exprs]
   `(with-progress-reporting (quick-bench (do ~@exprs) :verbose)))

-(defmacro bench'
+(defmacro run-quick-bench'
   [& exprs]
   `(quick-bench (do ~@exprs)))
+
+(defmacro run-bench
+  [& exprs]
+  `(with-progress-reporting (bench (do ~@exprs) :verbose)))
+
+(defmacro run-bench'
+  [& exprs]
+  `(bench (do ~@exprs)))

 (defn- run-test
   ([] (run-test #"^promesa.tests.*"))
@@ -37,18 +49,20 @@
       (System/exit fail)
       (System/exit 0))))

-;; (def normal-var
-;;   (delay 1))
+;; (defn simple-promise-chain-5-raw
+;;   []
+;;   @(as-> (CompletableFuture/completedFuture 1) $
+;;      (p/then' $ inc)
+;;      (p/then' $ inc)
+;;      (p/then' $ inc)
+;;      (p/then' $ inc)
+;;      (p/then' $ inc)))

-;; (def ^:dynamic *dynamic-var*
-;;   (delay 1))
-
-;; (defn bench-fn1
+;; (defn simple-completable-chain-5-raw
 ;;   []
-;;   (deref normal-var))
-
-;; (defn bench-fn2
-;;   []
-;;   (deref *dynamic-var*))
-
-
+;;   @(as-> (CompletableFuture/completedFuture 1) $
+;;      (.thenApply ^CompletionStage $ ^Function (pu/->FunctionWrapper inc))
+;;      (.thenApply ^CompletionStage $ ^Function (pu/->FunctionWrapper inc))
+;;      (.thenApply ^CompletionStage $ ^Function (pu/->FunctionWrapper inc))
+;;      (.thenApply ^CompletionStage $ ^Function (pu/->FunctionWrapper inc))
+;;      (.thenApply ^CompletionStage $ ^Function (pu/->FunctionWrapper inc))))


fix xml file output this time?

fix xml file output this time?

--- src/vip/data_processor/output/xml_helpers.clj
+++ src/vip/data_processor/output/xml_helpers.clj
@@ -1,14 +1,12 @@
 (ns vip.data-processor.output.xml-helpers
-  (:require [clojure.string :as str]
-            [korma.core :as korma])
+  (:require [korma.core :as korma])
   (:import [java.nio.file Files]
            [java.nio.file.attribute FileAttribute]))

 (defn create-xml-file
-  [{:keys [filename] :as ctx}]
-  (let [base-filename (-> filename (str/split #" ") last)
-        xml-file (Files/createTempFile
-                  base-filename ".xml" (into-array FileAttribute []))]
+  [{:keys [import-id] :as ctx}]
+  (let [xml-file (Files/createTempFile
+                  import-id ".xml" (into-array FileAttribute []))]
     (-> ctx
         (assoc :xml-output-file xml-file)
         (update :to-be-cleaned conj xml-file))))


Show "(no output)" when output is "", not just nil

--- src-cljs/frontend/components/build_head.cljs
+++ src-cljs/frontend/components/build_head.cljs
@@ -392,7 +392,7 @@
         [:div.properties
          [:div.test-name (format-test-name test)]
          [:div.test-file (:file test)]]
-        (let [message (or (:message test) "(no output)")
+        (let [message (or (:message test) "")
               display-message (if (:show-message test)
                                 message
                                 (second (re-find #"(?m)^\s*(.*)$" message)))
@@ -403,7 +403,9 @@
              [:div.expander {:role "button"
                              :on-click #(raise! owner [:show-test-message-toggled {:test-index (:i test)}])}
               expander-label])
-           display-message])]))))
+           (if (empty? message)
+             "(no output)"
+             display-message)])]))))

 (def initial-test-render-count 3)


Add copy for when the user is unkown

Add copy for when the user is unkown

--- src-cljs/frontend/components/build_head.cljs
+++ src-cljs/frontend/components/build_head.cljs
@@ -546,7 +546,8 @@

 (defn link-to-user [build]
   (when-let [user (:user build)]
-    (when (not (= "none" (:login user)))
+    (if (= "none" (:login user))
+      [:em "Unknown"]
       [:a {:href (vcs-url/profile-url user)}
        (build-model/ui-user build)])))


Revert a growth experiement for enterprise

--- src-cljs/frontend/components/build_head.cljs
+++ src-cljs/frontend/components/build_head.cljs
@@ -1046,12 +1046,17 @@
                 [:a.parallelism-link-head {:title (str "This build used " (:parallel build) " containers. Click here to change parallelism for future builds.")
                                            :on-click #(analytics/track-parallelism-build-header-click {})
                                            :href (build-model/path-for-parallelism build)}
-                 (str (:parallel build) "x out of "
-                      (min (+ (plan-model/usable-containers plan)
-                              (if (project-model/oss? project)
-                                plan-model/oss-containers
-                                0))
-                           (plan-model/max-parallelism plan)) "x")]]
+                 (let [parallelism (str (:parallel build) "x")]
+                   (if (enterprise?)
+                     parallelism
+                     (str parallelism
+                          " out of "
+                          (min (+ (plan-model/usable-containers plan)
+                                  (if (project-model/oss? project)
+                                    plan-model/oss-containers
+                                    0))
+                               (plan-model/max-parallelism plan))
+                          "x")))]]

                (when-let [urls (seq (:pull_request_urls build))]
                  ;; It's possible for a build to be part of multiple PRs, but it's rare
@@ -1432,12 +1437,17 @@
              [:a.parallelism-link-head {:title (str "This build used " (:parallel build) " containers. Click here to change parallelism for future builds.")
                                         :on-click #(analytics/track-parallelism-build-header-click {})
                                         :href (build-model/path-for-parallelism build)}
-              (str (:parallel build) "x out of "
-                   (min (+ (plan-model/usable-containers plan)
-                           (if (project-model/oss? project)
-                             plan-model/oss-containers
-                             0))
-                        (plan-model/max-parallelism plan)) "x")]]]
+              (let [parallelism (str (:parallel build) "x")]
+                (if (enterprise?)
+                  parallelism
+                  (str parallelism
+                       " out of "
+                       (min (+ (plan-model/usable-containers plan)
+                               (if (project-model/oss? project)
+                                 plan-model/oss-containers
+                                 0))
+                            (plan-model/max-parallelism plan))
+                       "x")))]]]
            (when (:usage_queued_at build)
              [:div.summary-items
               [:div.summary-item


Use hyphen in namespace name, properly call super.setUp()

--- test/src/clojure/neko/listeners/view_test.clj
+++ test/src/clojure/neko/listeners/view_test.clj
@@ -9,7 +9,7 @@
 ; terms of this license.  You must not remove this notice, or any other, from
 ; this software.

-(ns neko.listeners.view_test
+(ns neko.listeners.view-test
   "Tests for the neko.listeners.view namespace."
   {:author "Daniel Solano Gómez"}
   (:gen-class :main false
@@ -20,7 +20,7 @@
                         [testOnKey [] void]
                         [testOnLongClick [] void]
                         [testOnTouch [] void]]
-              :exposes-method {setUp superSetUp})
+              :exposes-methods {setUp superSetUp})
   (:import android.view.View)
   (:use neko.listeners.view
         junit.assert))
@@ -31,6 +31,7 @@
 (defn -setUp
   "Creates new view for testing."
   [this]
+  (.superSetUp this)
   (reset! test-view (View. (.getContext this)))
   (reset! clicks 0))


just display standard date for now

just display standard date for now

--- pedestal-app/app/src/semtag_web/partials.cljs
+++ pedestal-app/app/src/semtag_web/partials.cljs
@@ -59,7 +59,7 @@
      [:a {:href (path-to "#/type/" type)} type]])

 (defn- td-timestamp [datetime]
-  [:td.timestamp {:title (if datetime (.toISOString datetime) "")} (str datetime)])
+  [:td.timestamp {:title (if datetime (.toISOString datetime) "")} (str (.toLocaleDateString datetime))])

 ;;; partials
 (defpartial default-row [row fields]


Fix test metadata instructions

Fix test metadata instructions

The instructions didn't show.  Now they do.

--- src-cljs/frontend/components/build_head.cljs
+++ src-cljs/frontend/components/build_head.cljs
@@ -263,16 +263,16 @@

 (defn tests-ad [owner]
   [:div
-   [:p "We didn't find any test metadata for this build.  Here's how to get it:"
-       [:ul
-        [:li "For an inferred ruby test command, simply add the necessary "
-             [:a {:href "/docs/test-metadata#automatic-test-metadata-collection"} "formatter gem"]
-             " and then we'll collect it automatically."]
-        [:li "For another inferred test runner that you'd like us to add metadata support for, "
-             [:a {:on-click #(raise! owner [:intercom-dialog-raised])} "let us know"] "."]
-        [:li "For a custom test command, configure your test runner to write a JUnit XML report to a directory in $CIRCLE_TEST_REPORTS - see "
-             [:a {:ref ""} "the docs"] " for more information."]]
-       "With test metadata, we can provide better insight into your build results and in some cases speed up your parallel builds by more efficiently splitting your tests between containers."]])
+   "We didn't find any test metadata for this build.  Here's how to get it:"
+   [:ul
+    [:li "For an inferred ruby test command, simply add the necessary "
+     [:a {:href "/docs/test-metadata#automatic-test-metadata-collection"} "formatter gem"]
+     " and then we'll collect it automatically."]
+    [:li "For another inferred test runner that you'd like us to add metadata support for, "
+     [:a {:on-click #(raise! owner [:intercom-dialog-raised])} "let us know"] "."]
+    [:li "For a custom test command, configure your test runner to write a JUnit XML report to a directory in $CIRCLE_TEST_REPORTS - see "
+     [:a {:ref ""} "the docs"] " for more information."]]
+   "With test metadata, we can provide better insight into your build results and in some cases speed up your parallel builds by more efficiently splitting your tests between containers."])

 (defn build-tests-list [data owner]
   (reify


Show estimated time when running.

Show estimated time when running.

--- src-cljs/frontend/components/build_head.cljs
+++ src-cljs/frontend/components/build_head.cljs
@@ -1387,6 +1387,22 @@
        [:a {:href (routes/v1-build-path (vcs-url/org-name vcs-url) (vcs-url/repo-name vcs-url) build-number)}
           build-number]])))

+(defn expected-duration-v2
+  [build owner opts]
+  (reify
+    om/IDisplayName
+    (display-name [_] "Expected Duration")
+
+    om/IRender
+    (render [_]
+      (let [formatter (get opts :formatter datetime/as-duration)
+            previous-build (:previous_successful_build build)
+            past-ms (:build_time_millis previous-build)]
+        (html
+         [:div.summary-item
+          [:span.summary-label "Estimated: "]
+          [:span (formatter past-ms)]])))))
+
 (defn build-head-v2 [data owner]
   (reify
     om/IRender
@@ -1408,50 +1424,52 @@
                         :vcs-url (:vcs_url build)
                         :build-num (:build_num build)}]
         (html
-          [:div
-           [:div.summary-header
-            [:div.summary-items
-             [:div.summary-item
-              (builds-table/build-status-badge build)]
-             (if-not (:stop_time build)
-               (when (:start_time build)
-                 (build-running-status build))
-               (build-finished-status build))]
-            [:div.summary-items
-             (om/build previous-build-label build)
-             [:div.summary-item
-              [:span.summary-label "Parallelism: "]
-              (if (has-scope :write-settings data)
-                [:a.parallelsim-link-head {:title (str "This build used " (:parallel build) " containers. Click here to change parallelism for future builds.")
-                                           :href (build-model/path-for-parallelism build)}
-                 (str (:parallel build) "x")]
-                [:span (:parallel build) "x"])]]
-            (when (:usage_queued_at build)
-              [:div.summary-items
-               [:div.summary-item
-                [:span.summary-label "Queued: "]
-                [:span (queued-time build)]]])
-
-            [:div.summary-build-contents
-             [:div.summary-item
-              [:span.summary-label "Triggered by: "]
-              [:span (trigger-html build)]]
-
-             (when-let [urls (seq (:pull_request_urls build))]
-               (pull-requests urls))]]
-
-           (when-let  [canceler  (and  (=  (:status build) "canceled")
+         [:div
+          [:div.summary-header
+           [:div.summary-items
+            [:div.summary-item
+             (builds-table/build-status-badge build)]
+            (if-not (:stop_time build)
+              (when (:start_time build)
+                (build-running-status build))
+              (build-finished-status build))]
+           [:div.summary-items
+            (when (build-model/running? build)
+              (om/build expected-duration-v2 build))
+            (om/build previous-build-label build)
+            [:div.summary-item
+             [:span.summary-label "Parallelism: "]
+             (if (has-scope :write-settings data)
+               [:a.parallelsim-link-head {:title (str "This build used " (:parallel build) " containers. Click here to change parallelism for future builds.")
+                                          :href (build-model/path-for-parallelism build)}
+                (str (:parallel build) "x")]
+               [:span (:parallel build) "x"])]]
+           (when (:usage_queued_at build)
+             [:div.summary-items
+              [:div.summary-item
+               [:span.summary-label "Queued: "]
+               [:span (queued-time build)]]])
+
+           [:div.summary-build-contents
+            [:div.summary-item
+             [:span.summary-label "Triggered by: "]
+             [:span (trigger-html build)]]
+
+            (when-let [urls (seq (:pull_request_urls build))]
+              (pull-requests urls))]]
+
+          (when-let  [canceler  (and  (=  (:status build) "canceled")
                                       (:canceler build))]
-             [:div.summary-header
-              [:div.summary-items
-               [:div.summary-item
-                (build-canceler canceler github-endpoint)]]])
-           [:div.card
-            [:div.small-emphasis "Commits (" (-> build :all_commit_details count) ")"]
-            (om/build build-commits-v2 build-data)]
-           [:div.build-head-wrapper
-            [:div.build-head
-             (om/build build-sub-head-v2 data)]]])))))
+            [:div.summary-header
+             [:div.summary-items
+              [:div.summary-item
+               (build-canceler canceler github-endpoint)]]])
+          [:div.card
+           [:div.small-emphasis "Commits (" (-> build :all_commit_details count) ")"]
+           (om/build build-commits-v2 build-data)]
+          [:div.build-head-wrapper
+           [:div.build-head
+            (om/build build-sub-head-v2 data)]]])))))

 (defn rebuild-actions-v2 [{:keys [build project]} owner]
   (reify


Only declare invite modal management functions once

--- src-cljs/frontend/components/pages/team.cljs
+++ src-cljs/frontend/components/pages/team.cljs
@@ -78,137 +78,143 @@
                   (select-keys [:provider_id :handle :email :name])))))
         vcs-users-by-handle))

+;; functions for invite-teammates-modal component state manipulation
+
+(defn- select! [owner {:keys [handle] :as user}]
+  (om/set-state! owner [:org-members-by-handle handle :selected?] true))
+
+(defn- deselect! [owner {:keys [handle] :as user}]
+  (om/set-state! owner [:org-members-by-handle handle :selected?] false))
+
+(defn- selected? [owner {:keys [handle] :as user}]
+  (om/get-state owner [:org-members-by-handle handle :selected?]))
+
+(defn- set-entered-email! [owner {:keys [handle] :as user} value]
+  (om/set-state! owner [:org-members-by-handle handle :entered-email] value))
+
+(defn- get-entered-email [owner {:keys [handle] :as user}]
+  (om/get-state owner [:org-members-by-handle handle :entered-email]))
+
 (defn invite-teammates-modal [{:keys [selected-org close-fn show-modal?]} owner]
-  (letfn [(select! [{:keys [handle] :as user}]
-            (om/set-state! owner [:org-members-by-handle handle :selected?] true))
-          (deselect! [{:keys [handle] :as user}]
-            (om/set-state! owner [:org-members-by-handle handle :selected?] false))
-          (selected? [{:keys [handle] :as user}]
-            (om/get-state owner [:org-members-by-handle handle :selected?]))
-          (set-entered-email! [{:keys [handle] :as user} value]
-            (om/set-state! owner [:org-members-by-handle handle :entered-email] value))
-          (get-entered-email [{:keys [handle] :as user}]
-            (om/get-state owner [:org-members-by-handle handle :entered-email]))]
-    (let [{:keys [vcs-users-by-handle]} selected-org
-          users (when show-modal?
-                  (->> vcs-users-by-handle
-                       vals
-                       (remove :user?)
-                       (sort-by :handle)))
-          count-users (count users)]
-      (reify
-        om/IWillReceiveProps
-        (will-receive-props [_ new-props]
-          (let [new-selected-org (:selected-org new-props)
-                new-vcs-users (:vcs-users-by-handle new-selected-org)
-                old-vcs-users (get-in (om/get-props owner) [:selected-org :vcs-users-by-handle])
-                new-show-modal? (:show-modal? new-props)
-                component-users-by-handle (om/get-state owner :org-members-by-handle)]
-            (when (and new-show-modal?
-                       (not new-vcs-users))
-              (api/get-org-members (:name new-selected-org) (:vcs_type new-selected-org) (om/get-shared owner [:comms :api])))
-            (when (not= new-vcs-users old-vcs-users)
-              (om/set-state! owner
-                             :org-members-by-handle
-                             (into {}
-                                   (for [[handle {:keys [user? email]
-                                                  :as user}] new-vcs-users
-                                         :when (not user?)]
-                                     (if-let [component-user (get component-users-by-handle handle)]
-                                       [handle component-user]
-                                       (let [trimmed-email (some-> email gstr/trim)]
-                                         [handle {:entered-email trimmed-email
-                                                  :selected? (valid-email? trimmed-email)}]))))))))
-
-        om/IRenderState
-        (render-state [_ {:keys [org-members-by-handle]}]
-          (component
-           (html
-            [:div
-             (when show-modal?
-               (let [count-selected (count (filter (fn [[_ user]]
-                                                (:selected? user))
-                                              org-members-by-handle))
-                     count-with-email (count (filter (fn [[_ user]]
-                                                       (-> user :entered-email valid-email?))
-                                                     org-members-by-handle))]
-                 (modal/modal-dialog {:title "Invite Teammates"
-                                      :body
-                                      (element :body
-                                               (html
-                                                [:div
-                                                 (if-not (contains? selected-org :vcs-users-by-handle)
-                                                   [:div.loading-spinner common/spinner]
-                                                   (list
-                                                    [:.header
-                                                     "These are the people who are not using CircleCI yet. "
-                                                     [:span
-                                                      "We were able to fill in "
-                                                      [:b count-with-email]
-                                                      " of "
-                                                      [:b count-users]
-                                                      " email addresses for you."]]
-                                                    [:.table
-                                                     (om/build table/table
-                                                               {:rows users
-                                                                :key-fn :handle
-                                                                :columns [{:header "Username"
-                                                                           :cell-fn (fn [{:keys [handle] :as user}]
-                                                                                (element :avatars
-                                                                                (html
-                                                                                [:div
-                                                                                [:img.invite-gravatar {:src (gh-utils/make-avatar-url user
-                                                                                :size 50)}]
-                                                                                (str "  " handle)])))}
-                                                                          {:header "Email"
-                                                                           :cell-fn (fn [user]
-                                                                                (let [selected? (selected? user)
-                                                                                entered-email (get-entered-email user)]
-                                                                                (om/build form/text-field
-                                                                                {:on-change (fn [event]
-                                                                                (let [trimmed-input (gstr/trim (.. event -currentTarget -value))
-                                                                                is-valid (valid-email? trimmed-input)]
-                                                                                (set-entered-email! user trimmed-input)
-                                                                                (cond
-                                                                                (and (not selected?)
-                                                                                is-valid)
-                                                                                (select! user)
-                                                                                (and selected?
-                                                                                (not is-valid))
-                                                                                (deselect! user))))
-                                                                                :value entered-email
-                                                                                :size :medium
-                                                                                :validation-error (when (and (or selected?
-                                                                                (not (empty? entered-email)))
-                                                                                (not (valid-email? entered-email)))
-                                                                                (str entered-email " is not a valid email"))})))}
-                                                                          {:type :shrink
-                                                                           :cell-fn (fn [user]
-                                                                                (let [entered-email (get-entered-email user)
-                                                                                valid? (valid-email? entered-email)]
-                                                                                [:input {:type "checkbox"
-                                                                                :disabled (and (not valid?)
-                                                                                (not (empty? entered-email)))
-                                                                                :checked (selected? user)
-                                                                                :on-click #(if-let [checked? (.. % -currentTarget -checked)]
-                                                                                (when valid?
-                                                                                (select! user))
-                                                                                (deselect! user))}]))}]
-                                                                :striped? true})]))]))
-                                      :actions [(button/button {:on-click close-fn} "Cancel")
-                                                (forms/managed-button
-                                                 [:button.btn.btn-primary {:data-success-text "Sent"
-                                                                           :on-click #(do
-                                                                                (raise! owner [:invited-team-members {:invitees (invitees org-members-by-handle vcs-users-by-handle)
-                                                                                :vcs_type (:vcs_type selected-org)
-                                                                                :org-name (:name selected-org)}])
-                                                                                (close-fn))
-                                                                           :disabled (= 0 count-selected)}
-                                                  "Send "
-                                                  count-selected
-                                                  " Invites"
-                                                  [:i.fa.fa-envelope-o]])]
-                                      :close-fn close-fn})))])))))))
+  (reify
+    om/IWillReceiveProps
+    (will-receive-props [_ new-props]
+      (let [new-selected-org (:selected-org new-props)
+            new-vcs-users (:vcs-users-by-handle new-selected-org)
+            old-vcs-users (get-in (om/get-props owner) [:selected-org :vcs-users-by-handle])
+            new-show-modal? (:show-modal? new-props)
+            component-users-by-handle (om/get-state owner :org-members-by-handle)]
+        (when (and new-show-modal?
+                   (not new-vcs-users))
+          (api/get-org-members (:name new-selected-org) (:vcs_type new-selected-org) (om/get-shared owner [:comms :api])))
+        (when (not= new-vcs-users old-vcs-users)
+          (om/set-state! owner
+                         :org-members-by-handle
+                         (into {}
+                               (for [[handle {:keys [user? email]
+                                              :as user}] new-vcs-users
+                                     :when (not user?)]
+                                 (if-let [component-user (get component-users-by-handle handle)]
+                                   [handle component-user]
+                                   (let [trimmed-email (some-> email gstr/trim)]
+                                     [handle {:entered-email trimmed-email
+                                              :selected? (valid-email? trimmed-email)}]))))))))
+
+    om/IRenderState
+    (render-state [_ {:keys [org-members-by-handle]}]
+      (component
+       (html
+        [:div
+         (when show-modal?
+           (let [{:keys [vcs-users-by-handle]} selected-org
+                 users (->> vcs-users-by-handle
+                            vals
+                            (remove :user?)
+                            (sort-by :handle))
+                 count-users (count users)
+                 count-selected (count (filter (fn [[_ user]]
+                                                 (:selected? user))
+                                               org-members-by-handle))
+                 count-with-email (count (filter (fn [[_ user]]
+                                                   (-> user :entered-email valid-email?))
+                                                 org-members-by-handle))]
+             (modal/modal-dialog {:title "Invite Teammates"
+                                  :body
+                                  (element :body
+                                           (html
+                                            [:div
+                                             (if-not (contains? selected-org :vcs-users-by-handle)
+                                               [:div.loading-spinner common/spinner]
+                                               (list
+                                                [:.header
+                                                 "These are the people who are not using CircleCI yet. "
+                                                 [:span
+                                                  "We were able to fill in "
+                                                  [:b count-with-email]
+                                                  " of "
+                                                  [:b count-users]
+                                                  " email addresses for you."]]
+                                                [:.table
+                                                 (om/build table/table
+                                                           {:rows users
+                                                            :key-fn :handle
+                                                            :columns [{:header "Username"
+                                                                       :cell-fn (fn [{:keys [handle] :as user}]
+                                                                                (element :avatars
+                                                                                (html
+                                                                                [:div
+                                                                                [:img.invite-gravatar {:src (gh-utils/make-avatar-url user
+                                                                                :size 50)}]
+                                                                                (str "  " handle)])))}
+                                                                      {:header "Email"
+                                                                       :cell-fn (fn [user]
+                                                                                (let [selected? (selected? owner user)
+                                                                                entered-email (get-entered-email owner user)]
+                                                                                (om/build form/text-field
+                                                                                {:on-change (fn [event]
+                                                                                (let [trimmed-input (gstr/trim (.. event -currentTarget -value))
+                                                                                is-valid (valid-email? trimmed-input)]
+                                                                                (set-entered-email! owner user trimmed-input)
+                                                                                (cond
+                                                                                (and (not selected?)
+                                                                                is-valid)
+                                                                                (select! owner user)
+                                                                                (and selected?
+                                                                                (not is-valid))
+                                                                                (deselect! owner user))))
+                                                                                :value entered-email
+                                                                                :size :medium
+                                                                                :validation-error (when (and (or selected?
+                                                                                (not (empty? entered-email)))
+                                                                                (not (valid-email? entered-email)))
+                                                                                (str entered-email " is not a valid email"))})))}
+                                                                      {:type :shrink
+                                                                       :cell-fn (fn [user]
+                                                                                (let [entered-email (get-entered-email owner user)
+                                                                                valid? (valid-email? entered-email)]
+                                                                                [:input {:type "checkbox"
+                                                                                :disabled (and (not valid?)
+                                                                                (not (empty? entered-email)))
+                                                                                :checked (selected? owner user)
+                                                                                :on-click #(if-let [checked? (.. % -currentTarget -checked)]
+                                                                                (when valid?
+                                                                                (select! owner user))
+                                                                                (deselect! owner user))}]))}]
+                                                            :striped? true})]))]))
+                                  :actions [(button/button {:on-click close-fn} "Cancel")
+                                            (forms/managed-button
+                                             [:button.btn.btn-primary {:data-success-text "Sent"
+                                                                       :on-click #(do
+                                                                                (raise! owner [:invited-team-members {:invitees (invitees org-members-by-handle vcs-users-by-handle)
+                                                                                :vcs_type (:vcs_type selected-org)
+                                                                                :org-name (:name selected-org)}])
+                                                                                (close-fn))
+                                                                       :disabled (= 0 count-selected)}
+                                              "Send "
+                                              count-selected
+                                              " Invites"
+                                              [:i.fa.fa-envelope-o]])]
+                                  :close-fn close-fn})))])))))

 (defn- main-content [app owner]
   (reify


Trim user input in invite teammates modal

--- src-cljs/frontend/components/pages/team.cljs
+++ src-cljs/frontend/components/pages/team.cljs
@@ -14,7 +14,7 @@
             [frontend.components.pieces.button :as button]
             [frontend.routes :as routes]
             [frontend.state :as state]
-            [frontend.utils :as utils :include-macros true]
+            [frontend.utils :as utils :include-macros true :refer [valid-email?]]
             [frontend.utils.github :as gh-utils]
             [frontend.utils.vcs :as vcs-utils]
             [goog.string :as gstr]
@@ -77,16 +77,16 @@
                       (:email user))))))

 (defn invite-teammates-modal [{:keys [selected-org close-fn show-modal?]} owner]
-  (let [select-user! (fn [{:keys [login] :as user}]
-                       (om/set-state! owner [:org-members-by-login login :selected] true))
-        deselect-user! (fn [{:keys [login] :as user}]
-                         (om/set-state! owner [:org-members-by-login login :selected] false))
-        selected? (fn [{:keys [login] :as user}]
-                    (om/get-state owner [:org-members-by-login login :selected]))
-        set-email! (fn [{:keys [login] :as user} value]
-                       (om/set-state! owner [:org-members-by-login login :email] value))
-        get-email (fn [{:keys [login] :as user}]
-                    (om/get-state owner [:org-members-by-login login :email]))]
+  (letfn [(select-user! [{:keys [login] :as user}]
+            (om/set-state! owner [:org-members-by-login login :selected] true))
+          (deselect-user! [{:keys [login] :as user}]
+            (om/set-state! owner [:org-members-by-login login :selected] false))
+          (selected? [{:keys [login] :as user}]
+            (om/get-state owner [:org-members-by-login login :selected]))
+          (set-email! [{:keys [login] :as user} value]
+            (om/set-state! owner [:org-members-by-login login :email] value))
+          (get-email [{:keys [login] :as user}]
+            (om/get-state owner [:org-members-by-login login :email]))]
     (reify
       om/IWillReceiveProps
       (will-receive-props [_ new-props]
@@ -101,12 +101,14 @@
             (om/set-state! owner
                            :org-members-by-login
                            (into {}
-                                 (for [{:keys [login circle_member email]
+                                 (for [{:keys [login circle_member email id]
                                         :as user} new-vcs-users
-                                       :when (not circle_member)]
-                                   [login (-> user
-                                              (select-keys [:email :login :id])
-                                              (assoc :selected (utils/valid-email? email)))]))))))
+                                       :when (not circle_member)
+                                       :let [trimmed-email (some-> email gstr/trim)]]
+                                   [login {:email trimmed-email
+                                           :login login
+                                           :id id
+                                           :selected (valid-email? trimmed-email)}]))))))

       om/IRenderState
       (render-state [_ {:keys [org-members-by-login]}]
@@ -114,8 +116,12 @@
          (if show-modal?
            (let [users (remove :circle_member (:vcs-users selected-org))
                  count-users (count users)
-                 count-with-email (count (filter (comp utils/valid-email? :email last) org-members-by-login))
-                 count-selected (count (filter (comp :selected last) org-members-by-login))]
+                 count-with-email (count (filter (fn [[_ user]]
+                                                   (-> user :email valid-email?))
+                                                 org-members-by-login))
+                 count-selected (count (filter (fn [[_ user]]
+                                                 (:selected user))
+                                               org-members-by-login))]
              (modal/modal-dialog {:title "Invite Teammates"
                                   :body
                                   (element :body
@@ -151,17 +157,21 @@
                                                                                email (get-email user)]
                                                                              (om/build form/text-field
                                                                                {:on-change (fn [event]
-                                                                                (let [input (.. event -target -value)]
-                                                                                (set-email! user input)
-                                                                                (when (or (and (not is-selected)
-                                                                                (not (empty? input)))
-                                                                                (utils/valid-email? input))
-                                                                                (select-user! user))))
+                                                                                (let [trimmed-input (gstr/trim (.. event -currentTarget -value))
+                                                                                is-valid (valid-email? trimmed-input)]
+                                                                                (set-email! user trimmed-input)
+                                                                                (cond
+                                                                                (and (not is-selected)
+                                                                                is-valid)
+                                                                                (select-user! user)
+                                                                                (and is-selected
+                                                                                (not is-valid))
+                                                                                (deselect-user! user))))
                                                                                :value email
                                                                                :size :medium
                                                                                :validation-error (when (and (or is-selected
                                                                                (not (empty? email)))
-                                                                                (not (utils/valid-email? email)))
+                                                                                (not (valid-email? email)))
                                                                                (str email " is not a valid email"))})))}
                                                                {:type :shrink
                                                                 :cell-fn (fn [user]
@@ -185,7 +195,7 @@
                                                                                :org-name (:name selected-org)}])
                                                                                (close-fn))
                                                                        :disabled (or (empty? (invitees org-members-by-login))
-                                                                                (not (every? #(utils/valid-email? (:email %)) (invitees org-members-by-login))))}
+                                                                                (not (every? (comp valid-email? :email) (invitees org-members-by-login))))}
                                               "Send Invites "
                                               [:i.fa.fa-envelope-o]])]
                                   :close-fn close-fn}))


Formatting

Formatting

--- src/clj/clojurewerkz/statistiker/scaling.clj
+++ src/clj/clojurewerkz/statistiker/scaling.clj
@@ -68,7 +68,6 @@
   [maps key scale-fn-factory]
   (let [extracted (map #(get % key) maps)
         scale-f   (scale-fn-factory extracted)
-        scaled    (map scale-f extracted)
-        ]
+        scaled    (map scale-f extracted)]
     (map (fn [v scaled]
            (assoc v key scaled)) maps scaled)))


fix datetime outside re-form

fix datetime outside re-form

--- src/cljs/re_form/inputs/date_input_impl.cljs
+++ src/cljs/re_form/inputs/date_input_impl.cljs
@@ -160,7 +160,7 @@
            [:div.date-chevrons
             {:on-click #(on-change (dec-iso value))}
             [:i.material-icons "chevron_left"]])
-         [:div.date-input {:on-blur #(my-on-blur % on-blur)
+         [:div.date-input {:on-blur #(my-on-blur % (or on-blur identity))
                            :class (when-not (empty? errors) :error)}
           [:i.material-icons
            {:on-click


fefacto functions for check incomplete process

--- src/sandbox/multithread.clj
+++ src/sandbox/multithread.clj
@@ -64,61 +64,33 @@
          (map :lock-id)
          (into []))))

-(defn lock
-  "locks lock lock-id in locks map"
-  [locks process-id lock-id]
+(defn lock [locks process-id lock-id]
   (assoc locks lock-id {:locker process-id :locked true}))
-(defn unlock
-  "unlocks lock lock-id in locks map"
-  [locks process-id lock-id]
+
+(defn unlock [locks process-id lock-id]
   (assoc locks lock-id {:locker process-id :locked false}))
-;;=> The locks state contains its locked state and which process
-;; did lock it.
-
-(defn is-locked?
-  [process-id
-   instructions
-   locks
-   instruction]
-  (let [inst-locks (the-locks-inst-depends-on instructions
-                                              instruction)]
-    (some true? (map #(and (not= process-id ((get locks %)
-                                             :locker))
-                           ((get locks %) :locked))
-                     inst-locks))))
-;;=> If some of the locks the instruction depend on are locked (:locked true)
-;; and the locker is not its process, then it is considered as
-;; locked.
-
-  [scheduled]
-  (into [] (map  (fn [p] {:process-id (:process-id p)
-                          :instructions (into []
-                                              (map (fn [i] {:inst-id (:inst-id i)
-                                                            :inst-type (:inst-type i)
-                                                            :count (count (:times i))})
-                                                   (:instructions   p)))})
-                 scheduled)))
-;;=> this functions just adds :count n to the map maintained in
-;;"scheduled"
-
-(defn incomplete-instruction?
-  [instruction-w-count]
+
+(defn is-locked? [process-id instructions locks instruction]
+  (->> (the-locks-inst-depends-on instructions instruction)
+       (some #(and (not= process-id ((get locks %) :locker))
+                   ((get locks %) :locked)))))
+
+(defn sheduled-processes-parts [scheduled]
+  (map #(assoc-in
+         % [:instructions :count]
+         (count (get-in % [:instructions :times]))) scheduled))
+
+(defn incomplete-instruction? [instruction-w-count]
   (let [instr-effort (insts-effort (instruction-w-count :inst-type))
         instr-count (instruction-w-count :count)]
     (< instr-count instr-effort)))

-(defn incomplete-process?
-  [process-w-counts]
+(defn incomplete-process? [process-w-counts]
   (let [instrs-w-count (process-w-counts :instructions)]
-    (some true? (map incomplete-instruction?
-                     instrs-w-count))))
-
-(defn more-incomplete-processes?
-  [processes-w-count]
-  (some true? (map incomplete-process?
-                   processes-w-count)))
-;=> processes-w-count is just another name for the "scheduled"
-;; state map.
+    (some incomplete-instruction? instrs-w-count)))
+
+(defn more-incomplete-processes? [processes-w-count]
+  (some incomplete-process? processes-w-count))

 (defn find-inst-to-be-fired-in-process
          [locks


Add stats for pipeline input queue.

Add stats for pipeline input queue.

--- src/dsbdp/local_data_processing_pipeline.clj
+++ src/dsbdp/local_data_processing_pipeline.clj
@@ -217,7 +217,8 @@
                       (reduce
                         (fn [m pe]
                           (assoc m (get-id pe) (get-counts pe)))
-                        {}
+                        {:pipeline {:in (.value in-counter)
+                                    :dropped (.value in-drop-counter)}}
                         proc-elements))
      :interrupt (fn []
                   (reset! running false)


Re-work processing element id handling.

Re-work processing element id handling.

--- src/dsbdp/local_data_processing_pipeline.clj
+++ src/dsbdp/local_data_processing_pipeline.clj
@@ -58,8 +58,9 @@
                       (catch InterruptedException e
                         (if @running
                           (throw e)))))
-          thread-id (str "ProcessingElement_" id)
-          proc-loop (if (not (nil? id))
+          thread-id (if (not (nil? id))
+                      (str "ProcessingElement_" id))
+          proc-loop (if (not (nil? thread-id))
                       (ProcessingLoop.
                         thread-id
                         proc-fn)
@@ -70,6 +71,7 @@
                     (reset! running false)
                     (.interrupt proc-loop))
        :out-queue out-queue
+       :id id
        :thread-id thread-id})))

 (defn interrupt


Ease switching between queueing implementations.

--- src/dsbdp/local_data_processing_pipeline.clj
+++ src/dsbdp/local_data_processing_pipeline.clj
@@ -19,33 +19,52 @@

 (def ^:dynamic *queue-size* 100000)
-
-
+(def ^:dynamic *queue-setup* "LinkedTransferQueue_tryTransfer-counted-10ms")

 (defmacro create-queue
   []
-;  `(LinkedBlockingQueue. *queue-size*))
-;  `(ArrayBlockingQueue. *queue-size*))
-  `(LinkedTransferQueue.))
+  (println "Setting up queue creation for:" *queue-setup*)
+  (let [expr (condp (fn [^String v ^String s] (.startsWith s v)) *queue-setup*
+               "LinkedBlockingQueue" `(LinkedBlockingQueue. *queue-size*)
+               "ArrayBlockingQueue" `(ArrayBlockingQueue. *queue-size*)
+               "LinkedTransferQueue" `(LinkedTransferQueue.))]
+    (println expr)
+    expr))

 (defmacro enqueue
   [queue data enqueued-counter dropped-counter]
-;  `(.put ~queue ~data))
-;  `(.offer ~queue ~data))
-;  `(.transfer ~queue ~data))
-;  `(if (.hasWaitingConsumer ~queue)
-;     (do
-;       (.transfer ~queue ~data)
-;       (.inc ~enqueued-counter))
-;     (do
-;       (.inc ~dropped-counter)
-;       ;(sleep 1)
-;       )))
-;  `(if (.tryTransfer ~queue ~data)
-  `(if (.tryTransfer ~queue ~data 10 TimeUnit/MILLISECONDS)
-     (.inc ~enqueued-counter)
-     (.inc ~dropped-counter)))
-;  `(.tryTransfer ~queue ~data))
+  (println "Enqueueing data via:")
+  (let [expr (condp (fn [^String v ^String s] (.endsWith s v)) *queue-setup*
+               "put" `(.put ~queue ~data)
+               "offer" `(.offer ~queue ~data)
+               "transfer" `(.transfer ~queue ~data)
+               "transfer-counted-no-sleep" `(if (.hasWaitingConsumer ~queue)
+                                              (do
+                                                (.transfer ~queue ~data)
+                                                (.inc ~enqueued-counter))
+                                              (.inc ~dropped-counter))
+               "transfer-counted-sleep-1ms" `(if (.hasWaitingConsumer ~queue)
+                                               (do
+                                                 (.transfer ~queue ~data)
+                                                 (.inc ~enqueued-counter))
+                                               (do
+                                                 (.inc ~dropped-counter)
+                                                 (sleep 1)))
+               "tryTransfer" `(.tryTransfer ~queue ~data)
+               "tryTransfer-counted-no-timeout" `(if (.tryTransfer ~queue ~data)
+                                                   (.inc ~enqueued-counter)
+                                                   (.inc ~dropped-counter))
+               "tryTransfer-counted-1ms" `(if (.tryTransfer ~queue ~data 1 TimeUnit/MILLISECONDS)
+                                            (.inc ~enqueued-counter)
+                                            (.inc ~dropped-counter))
+               "tryTransfer-counted-10ms" `(if (.tryTransfer ~queue ~data 10 TimeUnit/MILLISECONDS)
+                                             (.inc ~enqueued-counter)
+                                             (.inc ~dropped-counter))
+               "tryTransfer-counted-100ms" `(if (.tryTransfer ~queue ~data 100 TimeUnit/MILLISECONDS)
+                                              (.inc ~enqueued-counter)
+                                              (.inc ~dropped-counter)))]
+    (println expr)
+    expr))

 (defmacro take-from-queue
   [^BlockingQueue queue]