Fixing small opt issues.

Fixing small opt issues.

--- src/clj/think/image/data_augmentation.clj
+++ src/clj/think/image/data_augmentation.clj
@@ -11,7 +11,12 @@
     [java.awt.geom AffineTransform]))

+(set! *warn-on-reflection* true)
+(set! *unchecked-math* true)
+
+
 (defn- generate-random-int-pixel
+  ^long
   []
   (think-pixel/pack-pixel (rand-int 255) (rand-int 255) (rand-int 255) 255))

@@ -107,7 +112,7 @@
   [^BufferedImage img noise-ratio]
   (let [width (.getWidth img)
         height (.getHeight img)
-        ^int pixels (imagez/get-pixels img)
+        ^ints pixels (imagez/get-pixels img)
         num-pixels (alength pixels)
         num-noisy-pixels (* noise-ratio num-pixels)
         locations-to-edit (take num-noisy-pixels (shuffle (range num-pixels)))
@@ -118,7 +123,7 @@
     out-image))

 ;; From BenB
-(defn- rotate-img-emb-impl [img r x y]
+(defn- rotate-img-emb-impl [^BufferedImage img r x y]
   (let [w (.getWidth img)
         h (.getHeight img)
         at (new java.awt.geom.AffineTransform)
@@ -147,14 +152,14 @@
 (defn rotate-img-embiggen
   "rotate the image by a given angle, increasing the size of the result
   image to ensure that it is fully contained."
-  ([img r] (rotate-img-emb-impl img r (* 0.5 (.getWidth img)) (* 0.5 (.getHeight img))))
+  ([^BufferedImage img r] (rotate-img-emb-impl img r (* 0.5 (.getWidth img)) (* 0.5 (.getHeight img))))
   ([img r x y] (rotate-img-emb-impl img r x y)))

-(defn make-noise-image [img]
+(defn make-noise-image [^BufferedImage img]
   (let [height (.getHeight img)
         width (.getWidth img)
         new-img (imagez/new-image width height)
-        pxls (imagez/get-pixels img)]
+        ^ints pxls (imagez/get-pixels img)]
     (dotimes [i (* width height)]
       (aset pxls i (generate-random-int-pixel)))
     (imagez/set-pixels new-img pxls)


Added reset button for search bar

Added reset button for search bar

--- src/cljs/electron_adventure/fileview.cljs
+++ src/cljs/electron_adventure/fileview.cljs
@@ -55,9 +55,10 @@
         [:button {:on-click #(rescan-folder @folder-select)} "Index"]]
       [:div
         [:label "Search"]
-        [:input {:on-change #(reset! search-crit (-> % .-target .-value))}]]
-      (let [crit @search-crit]
-        (doall (for [file (filter #(not= -1 (.indexOf (:name %) crit)) (sort-by :name @files))]
+        [:input {:value @search-crit :on-change #(reset! search-crit (-> % .-target .-value))}]
+        [:button {:on-click #(reset! search-crit "")} "x"]]
+      (let [crit (string/lower-case @search-crit)]
+        (doall (for [file (filter #(not= -1 (.indexOf (string/lower-case (:name %)) crit)) (sort-by :name @files))]
             ^{:key (:path file)}
             [:div
               ((if (= @player/selected-piece file)


Accessibility Improvements

Accessibility Improvements

--- src/cljs/salava/connections/ui/badge.cljs
+++ src/cljs/salava/connections/ui/badge.cljs
@@ -12,31 +12,30 @@

 (defn init-issuer-connections [state]
   (ajax/GET
-    (path-for "/obpv1/connections/connections_issuer")
-    {:handler (fn [data]
-                (swap! state assoc :issuers data))}))
+   (path-for "/obpv1/connections/connections_issuer")
+   {:handler (fn [data]
+               (swap! state assoc :issuers data))}))

 (defn init-data [state]
   (ajax/GET
-    (path-for "/obpv1/connections/connections_badge" true)
-    {:handler (fn [data]
+   (path-for "/obpv1/connections/connections_badge" true)
+   {:handler (fn [data]
                 ; (prn data)
-                (swap! state assoc :badges data
-                       :visible-area (session/get! :visible-area nil))
-                (init-issuer-connections state))}))
-
+               (swap! state assoc :badges data
+                      :visible-area (session/get! :visible-area nil))
+               (init-issuer-connections state))}))

 (defn unfollow [badge-id state]
   [:a {:href "#" :on-click #(ajax/POST
-                              (path-for (str "/obpv1/social/delete_connection_badge/" badge-id))
-                              {:response-format :json
-                               :keywords?       true
-                               :handler         (fn [data]
-                                                  (do
-                                                    (init-data state)))
-                               :error-handler   (fn [{:keys [status status-text]}]
-                                                  (.log js/console (str status " " status-text)))})}
-      (t :social/Unfollow)])
+                             (path-for (str "/obpv1/social/delete_connection_badge/" badge-id))
+                             {:response-format :json
+                              :keywords?       true
+                              :handler         (fn [data]
+                                                 (do
+                                                   (init-data state)))
+                              :error-handler   (fn [{:keys [status status-text]}]
+                                                 (.log js/console (str status " " status-text)))})}
+   (t :social/Unfollow)])

 (defn remove-issuer-from-favourites [issuer-id state]
   [:a {:href "#"
@@ -61,6 +60,11 @@
      (when (= @(cursor state [:visible-area]) panel-identity)
        [:div.panel-body
         [:table {:class "table" :summary (t :badge/Issuers)}
+         [:thead
+          [:tr
+           [:th {:style {:display "none"}}  "Logo"]
+           [:th {:style {:display "none"}} (t :badge/Name)]
+           [:th {:style {:display "none"}} "Action"]]]
          (into [:tbody]
                (for [issuer issuers
                      :let [{:keys [id name image_file]} issuer]]
@@ -68,10 +72,9 @@
                   [:td.name [:a {:href "#"
                                  :on-click #(do
                                               (mo/open-modal [:badge :issuer] id {:hide (fn [] (init-data state))})
-                                              (.preventDefault %)) }(if image_file [:img.badge-icon {:src (str "/" image_file) :alt (str name " icon")}]
-                                                                      [:span {:style {:width "30px" :display "inline-block" :margin-right "10px"} :dangerouslySetInnerHTML {:__html " "}}]) name]]
+                                              (.preventDefault %))} (if image_file [:img.badge-icon {:src (str "/" image_file) :alt (str name " icon")}]
+                                                                        [:span {:style {:width "30px" :display "inline-block" :margin-right "10px"} :dangerouslySetInnerHTML {:__html " "}}]) name]]
                   [:td.action (remove-issuer-from-favourites id state)]]))]])]))
-

 (defn badge-connections [badges state]
   (let [panel-identity :badges
@@ -82,7 +85,7 @@
       [:a {:href "#" :on-click #(do (.preventDefault %) (toggle-panel :badges visible-area-atom) #_(reset! (cursor state [:visible-area]) :badges))}
        [:h2 (str (t :badge/Badges) " (" (count badges) ")")]
        #_[:p {:style {:margin-top "5px"}} (t :connections/Badgeblockinfo)]
-         [:i.fa.fa-lg.panel-status-icon {:class icon-class}]]]
+       [:i.fa.fa-lg.panel-status-icon {:class icon-class}]]]
      (when (= @(cursor state [:visible-area]) panel-identity)
        [:div.panel-body
         [:table {:class "table" :summary (t :badge/Badgeviews)}
@@ -102,10 +105,8 @@
                                  :on-click #(do
                                               (mo/open-modal [:gallery :badges] {:badge-id id} {:hide (fn [] (init-data state))})
                                               ;(b/open-modal id false init-data state)
-                                              (.preventDefault %)) } name]]
+                                              (.preventDefault %))} name]]
                   [:td.action (unfollow id state)]]))]])]))
-
-

 (defn content [state]
   (let [badges (:badges @state)
@@ -122,7 +123,6 @@
      ;(user-connections)

-
 (defn handler [site-navi]
   (let [state (atom {:badges []
                      :issuers []})]


CMR-6283 fixed event publishing (#957)

CMR-6283 fixed event publishing (#957)

--- ingest-app/src/cmr/ingest/services/jobs.clj
+++ ingest-app/src/cmr/ingest/services/jobs.clj
@@ -262,9 +262,11 @@
 (defn trigger-autocomplete-suggestions-reindex
   [context]
   (let [providers (map :provider-id (mdb/get-providers context))]
-    (map #(ingest-events/publish-provider-event
-            context
-            (ingest-events/provider-autocomplete-suggestion-reindexing-event %)))))
+    (info "Sending events to reindex autocomplete suggestions in all providers:" (pr-str providers))
+    (doseq [provider providers]
+      (ingest-events/publish-provider-event
+        context
+        (ingest-events/provider-autocomplete-suggestion-reindexing-event provider)))))

 (def-stateful-job BulkUpdateStatusTableCleanup
   [_ system]


CMR-5072: Finished cleanup.

CMR-5072: Finished cleanup.

--- umm-spec-lib/src/cmr/umm_spec/legacy.clj
+++ umm-spec-lib/src/cmr/umm_spec/legacy.clj
@@ -1,14 +1,14 @@
 (ns cmr.umm-spec.legacy
   "Functions for parsing concepts where old-style UMM is expected but new umm-spec formats (like
   JSON) need to be supported."
-  (:require [cmr.common.mime-types :as mt]
-            [cmr.umm.umm-core :as umm]
-            [cmr.umm-spec.umm-spec-core :as umm-spec]))
+  (:require
+   [cmr.common.mime-types :as mt]
+   [cmr.umm.umm-core :as umm]
+   [cmr.umm-spec.umm-spec-core :as umm-spec]))

 (defn- parse-umm-json-concept
   [context {:keys [concept-type metadata format] :as concept-map}]
-  (when (= :granule concept-type)
-    (umm-spec/parse-metadata context concept-type format metadata)))
+  (umm-spec/parse-metadata context concept-type format metadata))

 (defn parse-concept
   "Returns UMM record from a concept map, like cmr.umm.umm-core/parse-concept, but supports additional


(PDB-2242) Remove some redundant param-specs

Existing moustache handlers each provided param specs that were used to
validing incoming request parameters. With the newly refactored
handlers.clj, most of these can go away. The extract-query function
includes a default which most handlers use.

--- src/puppetlabs/puppetdb/http/handlers.clj
+++ src/puppetlabs/puppetdb/http/handlers.clj
@@ -189,7 +189,6 @@
 (pls/defn-validated resources-routes :- bidi-schema/RoutePair
   [version :- s/Keyword]
   (extract-query
-   {:optional paging/query-params}
    (cmdi/routes
     (cmdi/ANY "" []
               (create-handler version "resources"  http-q/restrict-query-to-active-nodes))
@@ -216,7 +215,6 @@
 (pls/defn-validated catalog-routes :- bidi-schema/RoutePair
   [version :- s/Keyword]
   (extract-query
-   {:optional paging/query-params}
    (cmdi/routes

     (cmdi/ANY "" []
@@ -240,123 +238,116 @@

 (pls/defn-validated facts-routes :- bidi-schema/RoutePair
   [version :- s/Keyword]
-  (let [param-spec {:optional paging/query-params}]
-    (extract-query
-     {:optional paging/query-params}
-     (cmdi/routes
-      (cmdi/ANY "" []
-                (create-handler version "facts" http-q/restrict-query-to-active-nodes))
-
-      (cmdi/context ["/" (route-param :fact)]
-
-                    (cmdi/ANY "" []
-                              (create-handler version "facts"
-                                              http-q/restrict-fact-query-to-name
-                                              http-q/restrict-query-to-active-nodes
-                                              decode-route-params))
-
-                    (cmdi/ANY ["/" (route-param :value)] []
-                              (create-handler version "facts"
-                                              http-q/restrict-fact-query-to-name
-                                              http-q/restrict-fact-query-to-value
-                                              http-q/restrict-query-to-active-nodes
-                                              decode-route-params)))))))
+  (extract-query
+   (cmdi/routes
+    (cmdi/ANY "" []
+              (create-handler version "facts" http-q/restrict-query-to-active-nodes))
+
+    (cmdi/context ["/" (route-param :fact)]
+
+                  (cmdi/ANY "" []
+                            (create-handler version "facts"
+                                            http-q/restrict-fact-query-to-name
+                                            http-q/restrict-query-to-active-nodes
+                                            decode-route-params))
+
+                  (cmdi/ANY ["/" (route-param :value)] []
+                            (create-handler version "facts"
+                                            http-q/restrict-fact-query-to-name
+                                            http-q/restrict-fact-query-to-value
+                                            http-q/restrict-query-to-active-nodes
+                                            decode-route-params))))))

 (pls/defn-validated factset-routes :- bidi-schema/RoutePair
   [version :- s/Keyword]
-  (let [param-spec {:optional paging/query-params}]
-    (extract-query
-     {:optional paging/query-params}
-     (cmdi/routes
-      (cmdi/ANY "" []
-                (create-handler version "factsets" http-q/restrict-query-to-active-nodes))
-
-      (cmdi/context ["/" :node]
-                    (cmdi/ANY "" []
-                              (comp (factset-status version)
-                                    decode-route-params))
-
-                    (cmdi/ANY "/facts" []
-                              (-> (create-handler version "factsets" http-q/restrict-query-to-node)
-                                  (comp decode-route-params)
-                                  (parent-check version :factset :node))))))))
+  (extract-query
+   (cmdi/routes
+    (cmdi/ANY "" []
+              (create-handler version "factsets" http-q/restrict-query-to-active-nodes))
+
+    (cmdi/context ["/" :node]
+                  (cmdi/ANY "" []
+                            (comp (factset-status version)
+                                  decode-route-params))
+
+                  (cmdi/ANY "/facts" []
+                            (-> (create-handler version "factsets" http-q/restrict-query-to-node)
+                                (comp decode-route-params)
+                                (parent-check version :factset :node)))))))

 (pls/defn-validated fact-names-routes :- bidi-schema/RoutePair
   [version :- s/Keyword]
-  (extract-query {:optional paging/query-params}
+  (extract-query
+   (cmdi/ANY "" []
+             (comp
+              (fn [{:keys [params globals puppetdb-query]}]
+                (let [puppetdb-query (assoc-when puppetdb-query :order_by [[:name :ascending]])]
+                  (produce-streaming-body
+                   version
+                   (http-q/validate-distinct-options! (merge (keywordize-keys params) puppetdb-query))
+                   (narrow-globals globals))))
+              (http-q/restrict-query-to-entity "fact_names")))))
+
+(pls/defn-validated node-routes :- bidi-schema/RoutePair
+  [version :- s/Keyword]
+  (extract-query
+   (cmdi/routes
+    (cmdi/ANY "" []
+              (create-handler version "nodes" http-q/restrict-query-to-active-nodes))
+    (cmdi/context ["/" (route-param :node)]
+                  (cmdi/ANY "" []
+                            (-> (node-status version)
+                                (comp decode-route-params)
+                                validate-no-query-params))
+
+                  (cmdi/context "/facts"
+                                (-> (facts-routes version)
+                                    (append-handler (comp http-q/restrict-query-to-node decode-route-params))
+                                    (wrap-with-parent-check version :node :node)))
+                  (cmdi/context "/resources"
+                                (-> (resources-routes version)
+                                    (append-handler (comp http-q/restrict-query-to-node decode-route-params))
+                                    (wrap-with-parent-check version :node :node)))))))
+
+(pls/defn-validated environments-routes :- bidi-schema/RoutePair
+  [version :- s/Keyword]
+  (cmdi/routes
+   (extract-query
+    (cmdi/ANY "" []
+              (create-handler version "environments")))
+   (cmdi/context ["/" (route-param :environment)]
                  (cmdi/ANY "" []
-                           (comp
-                            (fn [{:keys [params globals puppetdb-query]}]
-                              (let [puppetdb-query (assoc-when puppetdb-query :order_by [[:name :ascending]])]
-                                (produce-streaming-body
-                                 version
-                                 (http-q/validate-distinct-options! (merge (keywordize-keys params) puppetdb-query))
-                                 (narrow-globals globals))))
-                            (http-q/restrict-query-to-entity "fact_names")))))
-
-(pls/defn-validated node-routes :- bidi-schema/RoutePair
-  [version :- s/Keyword]
-  (let [param-spec {:optional paging/query-params}]
-    (extract-query
-     {:optional paging/query-params}
-     (cmdi/routes
-      (cmdi/ANY "" []
-                (create-handler version "nodes" http-q/restrict-query-to-active-nodes))
-      (cmdi/context ["/" (route-param :node)]
-                    (cmdi/ANY "" []
-                              (-> (node-status version)
-                                  (comp decode-route-params)
-                                  validate-no-query-params))
-
+                           (validate-no-query-params (environment-status version)))
+
+                 (wrap-with-parent-check
+                  (cmdi/routes
+                   (extract-query
                     (cmdi/context "/facts"
                                   (-> (facts-routes version)
-                                      (append-handler (comp http-q/restrict-query-to-node decode-route-params))
-                                      (wrap-with-parent-check version :node :node)))
+                                      (append-handler http-q/restrict-query-to-environment))))
+
+                   (extract-query
                     (cmdi/context "/resources"
                                   (-> (resources-routes version)
-                                      (append-handler (comp http-q/restrict-query-to-node decode-route-params))
-                                      (wrap-with-parent-check version :node :node))))))))
-
-(pls/defn-validated environments-routes :- bidi-schema/RoutePair
-  [version :- s/Keyword]
-  (let [param-spec {:optional paging/query-params}]
-    (cmdi/routes
-     (extract-query
-      (cmdi/ANY "" []
-                (create-handler version "environments")))
-     (cmdi/context ["/" (route-param :environment)]
-                   (cmdi/ANY "" []
-                             (validate-no-query-params (environment-status version)))
-
-                   (wrap-with-parent-check
-                    (cmdi/routes
-                     (extract-query
-                      (cmdi/context "/facts"
-                                    (-> (facts-routes version)
-                                        (append-handler http-q/restrict-query-to-environment))))
-
-                     (extract-query
-                      (cmdi/context "/resources"
-                                    (-> (resources-routes version)
-                                        (append-handler http-q/restrict-query-to-environment))))
-
-                     (extract-query
-                      (cmdi/context "/reports"
-                                    (-> (reports-routes version)
-                                        (append-handler http-q/restrict-query-to-environment))))
-
-                     (extract-query
-                      {:optional (concat
-                                  ["query"
-                                   "distinct_resources"
-                                   "distinct_start_time"
-                                   "distinct_end_time"]
-                                  paging/query-params)}
-
-                      (cmdi/context "/events"
-                                    (-> (events-routes version)
-                                        (append-handler http-q/restrict-query-to-environment)))))
-                    version :environment :environment)))))
+                                      (append-handler http-q/restrict-query-to-environment))))
+
+                   (extract-query
+                    (cmdi/context "/reports"
+                                  (-> (reports-routes version)
+                                      (append-handler http-q/restrict-query-to-environment))))
+
+                   (extract-query
+                    {:optional (concat
+                                ["query"
+                                 "distinct_resources"
+                                 "distinct_start_time"
+                                 "distinct_end_time"]
+                                paging/query-params)}
+
+                    (cmdi/context "/events"
+                                  (-> (events-routes version)
+                                      (append-handler http-q/restrict-query-to-environment)))))
+                  version :environment :environment))))

 (pls/defn-validated fact-contents-routes :- bidi-schema/RoutePair
   [version :- s/Keyword]


Raise an error if sparql resource file is not found on resource path

--- src/rdf-repository/grafter/rdf/sparql.clj
+++ src/rdf-repository/grafter/rdf/sparql.clj
@@ -4,7 +4,8 @@
             [grafter.rdf.repository :as repo]
             [grafter.rdf.io :refer [->sesame-rdf-type]]
             [clojure.java.io :refer [resource]]
-            [clojure.string :as str]))
+            [clojure.string :as str]
+            [clojure.java.io :as io]))

 (defn- get-clause-pattern [clause-name key]
   (cond
@@ -63,7 +64,10 @@
   (spog r {:s (java.net.URI. \"http://example.org/data/a-triple\")}) ;; triples for given subject s.
   "
   ([sparql-file]
-   (partial query sparql-file))
+   (if (io/resource sparql-file)
+     (partial query sparql-file)
+     (throw (ex-info "Could not find sparql file on resource path" {:error :resource-file-not-found
+                                                                    :resource-path sparql-file}))))
   ([sparql-file repo]
    (query sparql-file {} repo))
   ([sparql-file bindings repo]


[#2127] Refactor test

[#2127] Refactor test

--- backend/test/akvo/lumen/lib/import/flow_common_test.clj
+++ backend/test/akvo/lumen/lib/import/flow_common_test.clj
@@ -4,96 +4,38 @@

 (deftest form-submission-nulls-values
   (testing "flow only send values for questions that are filled"
-    (let [groups [{:id "597899156"
-                   :name "Repeated"
+    (let [groups [{:id "1G"
                    :repeatable true}
-                  {:id "617319144"
-                   :name "Non repeatable"
-                   :repeatable false}]
-          questions [{:groupId "597899156",
-                      :name "Name",
-                      :groupName "Repeated",
-                      :createdAt "2020-06-09T13:47:32.786Z",
-                      :type "FREE_TEXT",
-                      :personalData false,
-                      :variableName nil,
-                      :id "583119147",
-                      :order 1,
-                      :modifiedAt "2020-06-09T13:47:53.534Z"}
-                     {:groupId "597899156",
-                      :name "Age",
-                      :groupName "Repeated",
-                      :createdAt "2020-06-09T13:47:34.083Z",
-                      :type "NUMBER",
-                      :personalData false,
-                      :variableName nil,
-                      :id "594979148",
-                      :order 2,
-                      :modifiedAt "2020-06-09T13:48:07.215Z"}
-                     {:groupId "597899156",
-                      :name "Likes Pizza",
-                      :groupName "Repeated",
-                      :createdAt "2020-06-09T13:47:35.352Z",
-                      :type "OPTION",
-                      :personalData false,
-                      :variableName nil,
-                      :id "609479145",
-                      :order 3,
-                      :modifiedAt "2020-06-09T13:48:57.306Z"}
-                     {:groupId "617319144",
-                      :name "Family name",
-                      :groupName "Non repeatable",
-                      :createdAt "2020-06-09T13:46:35.817Z",
-                      :type "FREE_TEXT",
-                      :personalData false,
-                      :variableName nil,
-                      :id "617309149",
-                      :order 1,
-                      :modifiedAt "2020-06-09T13:47:25.423Z"}
-                     {:groupId "617319144",
-                      :name "Location",
-                      :groupName "Non repeatable",
-                      :createdAt "2020-06-09T13:47:05.152Z",
-                      :type "FREE_TEXT",
-                      :personalData false,
-                      :variableName nil,
-                      :id "588869155",
-                      :order 2,
-                      :modifiedAt "2020-06-09T13:47:20.516Z"}]]
-      (let [responses {"597899156" [{"583119147" "Mary",
-                                     "609479145" [{"text" "yes", "code" "1"}],
-                                     "594979148" 36.0}
-                                    {"583119147" "Pol",
-                                     "609479145" [{"text" "no", "code" "2"}],
-                                     "594979148" 12.0}],
-                       "617319144" [{"588869155" "Sevilla",
-                                     "617309149" "Poppins"}]}]
-        (is (= [{"588869155" "Sevilla", "617309149" "Poppins"}
-                {"583119147" "Mary",
-                 "609479145" [{"text" "yes", "code" "1"}],
-                 "594979148" 36.0}]
+                  {:id "2G"
+                   :repeatable false}]]
+      (let [responses {"1G" [{"1G1Q" "A"
+                              "1G2Q" [{"text" "yes", "code" "1"}]
+                              "1G3Q" 36.0}
+                             {"1G1Q" "Pol"
+                              "1G2Q" [{"text" "no", "code" "2"}]
+                              "1G3Q" 12.0}]
+                       "2G" [{"1" "A"
+                              "2" "B"}]}]
+        (is (= [{"1" "A"
+                 "2" "B"}
+                {"1G1Q" "A"
+                 "1G2Q" [{"text" "yes", "code" "1"}]
+                 "1G3Q" 36.0}]
                (flow-common/question-responses groups responses))))
-      (let [responses {"597899156" [{"609479145" [{"text" "yes", "code" "1"}],
-                                     "594979148" 36.0}
-                                    {"583119147" "Pol",
-                                     "609479145" [{"text" "no", "code" "2"}],
-                                     "594979148" 12.0}],
-                       "617319144" [{"588869155" "Sevilla",
-                                     "617309149" "Poppins"}]}]
-        (is (= [{"588869155" "Sevilla", "617309149" "Poppins"}
-                {"609479145" [{"text" "yes", "code" "1"}], "594979148" 36.0}]
+      (let [responses {"1G" [{"1G2Q" [{"text" "yes" "code" "1"}]
+                              "1G3Q" 36.0}
+                             {"1G1Q" "Pol"
+                              "1G3Q" 12.0}]
+                       "2G" [{"2G1Q" "A"
+                              "2G2Q" "B"}]}]
+        (is (= [{"2G1Q" "A"
+                 "2G2Q" "B"}
+                {"1G2Q" [{"text" "yes", "code" "1"}]
+                 "1G3Q" 36.0}]
                (flow-common/question-responses groups responses))))
-      (let [responses {"597899156" [{"609479145" [{"text" "yes", "code" "1"}],
-                                     "594979148" 36.0}
-                                    {"583119147" "Pol",
-                                     "594979148" 12.0}],
-                       "617319144" [{"588869155" "Sevilla",
-                                     "617309149" "Poppins"}]}]
-        (is (= [{"588869155" "Sevilla", "617309149" "Poppins"}
-                {"609479145" [{"text" "yes", "code" "1"}], "594979148" 36.0}]
-               (flow-common/question-responses groups responses))))
-      (let [responses {"597899156" [{}
-                                    {}],
-                       "617319144" [{"617309149" "Poppins"}]}]
-        (is (= [{"617309149" "Poppins"} {}]
+      (let [responses {"1G" [{}
+                             {}]
+                       "2G" [{"2G2Q" "B"}]}]
+        (is (= [{"2G2Q" "B"}
+                {}]
                (flow-common/question-responses groups responses)))))))


Simplify om/transact! calls (no need to pass in keys to re-query)

This is because om/transact! implicitly includes a request to
update the component initiating the transaction in the transaction:

  (om/transact! c `([(some/action ...)]))

becomes

  (om/transact! c `([(some/action ...) ~c]))


Renaming background's :data-import -> :data-load

This will make it clearer than it's a separate action from the actual
JSON import done on display.  Removed leftover state set from back when
that handler got JSON data.

--- src/background/relevance/background.cljs
+++ src/background/relevance/background.cljs
@@ -98,7 +98,7 @@
   ::initialize
   (fn [_]
     (go
-      (dispatch [:data-import (<! (data/get))])
+      (dispatch [:data-load (<! (data/get))])
       (dispatch [::window-focus {:windowId (:id (<! (windows/get-last-focused {:populate false})))}])
       (dispatch [:idle-state-change {:newState (<! (idle/query-state 30))}]))
     {:app-state    {}
@@ -106,7 +106,7 @@

 (register-handler
-  :data-import
+  :data-load
   (fn [app-state [_ new-data]]
     (console/trace "New data on import" new-data)
     ;; Create a new id if we don't have one
@@ -129,7 +129,6 @@
         (dispatch [:handle-deactivation old-tab (:time suspend-info)])))
     (-> app-state
         (assoc-in [:ui-state :section] :time-track)
-        (assoc-in [:app-state :import] nil)
         (assoc :hookup-done? true)
         (assoc :data (assoc new-data :suspend-info nil)))))


more mk-assignments refactoring

more mk-assignments refactoring

--- src/clj/backtype/storm/daemon/nimbus.clj
+++ src/clj/backtype/storm/daemon/nimbus.clj
@@ -57,6 +57,7 @@

 (declare reassign-topology)
 (declare delay-event)
+(declare mk-assignments)

 (defn kill-transition [nimbus storm-id]
   (fn [kill-time]
@@ -246,6 +247,10 @@
               supervisor-ids))
        )))

+(defn get-node->host [storm-cluster-state callback]
+  (->> (all-supervisor-info storm-cluster-state callback)
+       (map-val :hostname)))
+
 (defn- available-slots
   [conf storm-cluster-state callback]
   (let [supervisor-ids (.supervisors storm-cluster-state callback)
@@ -260,14 +265,13 @@
         ;;   )
         all-slots (map-val (comp set :worker-ports) supervisor-infos)
         existing-slots (assigned-slots storm-cluster-state)
-        ]
-    [(map-val :hostname supervisor-infos)
-     (mapcat
-       (fn [[id slots]]
-         (for [s (set/difference slots (existing-slots id))]
-           [id s]))
-       all-slots)
-      ]))
+        ]
+    (mapcat
+     (fn [[id slots]]
+       (for [s (set/difference slots (existing-slots id))]
+         [id s]))
+     all-slots)
+    ))

 (defn state-spout-parallelism [state-spout-spec]
   (-> state-spout-spec .get_common thrift/parallelism-hint))
@@ -415,8 +419,9 @@
 ;; TODO: slots that have dead task should be reused as long as supervisor is active

 ;; public so it can be mocked out
-(defn compute-new-task->node+port [conf storm-id existing-assignment storm-cluster-state available-slots callback task-heartbeats-cache]
-  (let [existing-assigned (reverse-map (:task->node+port existing-assignment))
+(defn compute-new-task->node+port [conf storm-id existing-assignment storm-cluster-state callback task-heartbeats-cache]
+  (let [available-slots (available-slots conf storm-cluster-state callback)
+        existing-assigned (reverse-map (:task->node+port existing-assignment))
         storm-conf (read-storm-conf conf storm-id)
         all-task-ids (set (.task-ids storm-cluster-state storm-id))
         alive-ids (set (alive-tasks conf storm-id storm-cluster-state
@@ -462,12 +467,13 @@
   (let [conf (:conf nimbus)
         storm-cluster-state (:storm-cluster-state nimbus)
         callback (fn [& ignored] (transition! nimbus storm-id :monitor))
+        node->host (get-node->host storm-cluster-state callback)

         existing-assignment (.assignment-info storm-cluster-state storm-id nil)
-        [node->host available-slots] (available-slots conf storm-cluster-state callback)
         task->node+port (compute-new-task->node+port conf storm-id existing-assignment
-                                                     storm-cluster-state available-slots
-                                                     callback (:task-heartbeats-cache nimbus))
+                                                     storm-cluster-state callback
+                                                     (:task-heartbeats-cache nimbus))
+
         all-node->host (merge (:node->host existing-assignment) node->host)
         reassign-ids (changed-ids (:task->node+port existing-assignment) task->node+port)
         now-secs (current-time-secs)


remove unecessary code

remove unecessary code

--- src/clj/backtype/storm/daemon/nimbus.clj
+++ src/clj/backtype/storm/daemon/nimbus.clj
@@ -258,18 +258,11 @@
   (->> (all-supervisor-info storm-cluster-state callback)
        (map-val :hostname)))

+;; TODO: this needs to be mocked out
 (defn- available-slots
   [conf storm-cluster-state callback]
   (let [supervisor-ids (.supervisors storm-cluster-state callback)
-        supervisor-infos (all-supervisor-info storm-cluster-state callback)
-        ;; TODO: this is broken. need to maintain a map since last time
-        ;; supervisor hearbeats like is done for tasks
-        ;; maybe it's ok to trust ephemeral nodes here?
-        ;;[[id info]]
-        ;; (when (< (time-delta (:time-secs info))
-        ;;          (conf NIMBUS-SUPERVISOR-TIMEOUT-SECS))
-        ;;   [[id info]]
-        ;;   )
+        supervisor-infos (all-supervisor-info storm-cluster-state callback)
         all-slots (map-val (comp set :worker-ports) supervisor-infos)
         existing-slots (assigned-slots storm-cluster-state)
         ]
@@ -412,7 +405,7 @@

 ;; public so it can be mocked out
 (defn compute-new-task->node+port [conf storm-id existing-assignment storm-cluster-state callback task-heartbeats-cache scratch?]
-  (let [available-slots (available-slots conf storm-cluster-state callback)
+  (let [available-slots (available-slots conf storm-cluster-state callback)
         storm-conf (read-storm-conf conf storm-id)
         all-task-ids (set (.task-ids storm-cluster-state storm-id))


Fix setting of :is-random-replacement in autoconstruction; lein release :patch

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -631,7 +631,7 @@
                                          (cons (:genome parent1) (:ancestors parent1))
                                          (:ancestors parent1)))
            :is-random-replacement
-           (if variant false true)
+           (if use-child false true)
       )))

 ;; @@


cleanup flush

cleanup flush

--- src/main/shadow/cljs/build.clj
+++ src/main/shadow/cljs/build.clj
@@ -1918,65 +1918,57 @@
    (with-logged-time
      [state {:type :flush-sources
              :source-names source-names}]
-     (doseq [{:keys [type name input last-modified] :as src}
+     (doseq [{:keys [type js-name name input output last-modified source-map] :as src}
              (->> source-names
                   (map #(get-in state [:sources %])))
-             :let [target (io/file public-dir cljs-runtime-path name)]
-
-             ;; skip files we already have since source maps are kinda expensive to generate
-             :when (or (not (.exists target))
+             :let [js-file
+                   (io/file public-dir cljs-runtime-path js-name)
+
+                   src-file
+                   (io/file public-dir cljs-runtime-path name)
+
+                   src-map?
+                   (and source-map (:source-map state))
+
+                   src-map-file
+                   (io/file public-dir cljs-runtime-path (str js-name ".map"))]
+
+             ;; skip files we already have
+             :when (or (not (.exists js-file))
                        (zero? last-modified)
-                       (> (or (:compiled-at src) ;; js is not compiled but maybe modified
-                              last-modified)
-                          (.lastModified target)))]
-
-       (io/make-parents target)
-
-       (case type
-         ;; cljs needs to flush the generated .js, for source-maps also the .cljs and a .map
-         :cljs
-         (do (let [{:keys [source-map js-name output]} src
-                   js-target (io/file public-dir cljs-runtime-path js-name)]
-
-               (when (nil? output)
-                 (throw (ex-info (format "no output for resource: %s" js-name) src)))
-
-               ;; must not modify output in any way, will mess up source maps otherwise
-               (spit js-target output)
-
-               ;; source-map on the resource is always generated
-               ;; only output it though if globally activated
-               (when (and source-map (:source-map state))
-                 (let [source-map-name (str js-name ".map")]
-                   (spit (io/file public-dir cljs-runtime-path source-map-name)
-                     (sm/encode
-                       {name source-map}
-                       {:lines
-                        (-> (StringReader. output)
-                            (BufferedReader.)
-                            (line-seq)
-                            (count))
-                        :file js-name
-                        :preamble-line-count 0}))
-                   )))
-
-             ;; spit original source, cljs needed for source maps
-             (spit target @input))
-
-         ;; js just needs itself
-         ;; FIXME: needs to flush more when js processing is added
-         :js
-         (do (spit target (:output src))
-             ;; foreign libs should play nice with goog require/import and tell what they provide
-             (when (:foreign src)
-               (spit target (make-foreign-js-source src) :append true)
-               ))
-
-         (throw (ex-info "cannot flush" (dissoc src :input :output)))
-         ))
+                       ;; js is not compiled but maybe modified
+                       (> (or (:compiled-at src) last-modified)
+                          (.lastModified js-file))
+                       (and src-map? (or (not (.exists src-file))
+                                         (not (.exists src-map-file)))))]
+
+       (io/make-parents js-file)
+
+       ;; must not modify output in any way, will mess up source maps otherwise
+       (spit js-file output)
+
+       (when src-map?
+         ;; spit original source, needed for source maps
+         (spit src-file @input)
+
+         (spit src-map-file
+           (sm/encode
+             {name source-map}
+             ;; very important that :lines is accurate for closure source maps, otherwise unused
+             {:lines
+              (-> (StringReader. output)
+                  (BufferedReader.)
+                  (line-seq)
+                  (count))
+              :file js-name
+              :preamble-line-count 0})))
+
+       ;; foreign libs should play nice with goog require/import and tell what they provide
+       ;; FIXME: this modifies the ouput, but foreign files have no source maps anyways
+       (when (:foreign src)
+         (spit js-file (make-foreign-js-source src) :append true)))

      state)))
-

 ;; FIXME: manifest should be custom step
@@ -2399,7 +2391,7 @@
        (every? #(str/starts-with? (str %) "goog.") provides)
        ))

-(defn flush-unoptmized-module!
+(defn flush-unoptimized-module!
   [{:keys [dev-inline-js public-dir public-path unoptimizable] :as state}
    {:keys [default js-name name prepend prepend-js append-js sources web-worker] :as mod}]
   (let [inlineable-sources
@@ -2494,7 +2486,7 @@
     (flush-manifest public-dir build-modules)

     (doseq [mod build-modules]
-      (flush-unoptmized-module! state mod))
+      (flush-unoptimized-module! state mod))

     state
     ))


[#248] update akvo-flow clojars version

[#248] update akvo-flow clojars version

--- api/project.clj
+++ api/project.clj
@@ -15,7 +15,7 @@
                  [ring/ring-json "0.4.0"]
                  [ring-jetty-component "0.3.1"]
                  [commons-fileupload "1.3.1"]
-                 [org.akvo.flow/akvo-flow "20221115-123123.ac209264" :classifier "classes" :exclusions [org.simplejavamail/simple-java-mail]]
+                 [org.akvo.flow/akvo-flow "20221116-063527.ad991252" :classifier "classes" :exclusions [org.simplejavamail/simple-java-mail]]
                  [org.akvo/commons "0.4.5" :exclusions [org.clojure/tools.nrepl]]
                  [raven-clj "1.5.0"]
                  [javax.jdo/jdo2-api "2.3-eb"]


data flow creation

data flow creation

--- src/clj/algorithms_clj/macro_initiation.clj
+++ src/clj/algorithms_clj/macro_initiation.clj
@@ -554,6 +554,46 @@
 ;; - Find something else...
 ;;
 ;; Show that macros can be used at the business level as well
-;; --------------------------------------------------------
-
-;; TODO
+;;
+;; Other ideas:
+;; - Financial product: create a defrecord with the right
+;; protocols given data describing the product
+;; - Product a data flow for a financial product based
+;; on its dependencies => reactive!
+;; - Produce a data flow for a simple computation
+;; --------------------------------------------------------
+
+(def computation-tree [+ :a [* :b :c]])
+
+(defn collect-dependencies
+  [tree]
+  (walk/postwalk
+    (fn [node]
+      (cond
+        (keyword? node) #{node}
+        (vector? node) (apply clojure.set/union node)
+        :else #{}))
+    tree))
+
+(defn keyword->symbol
+  [k]
+  (symbol (name k)))
+
+(defprotocol IEvalExpr
+  (eval-expr [this] "Evaluate the expression"))
+
+(defmacro def-data-flow
+  [name tree]
+  (let [deps (sort (map keyword->symbol (collect-dependencies tree)))]
+    `(defrecord ~name ~(vec deps)
+       IEvalExpr
+       (eval-expr [this] 1)
+       )))
+
+(def-data-flow Expr [+ :a [* :b :c]])
+
+(defn test-data-flow
+  []
+  (let [e (map->Expr {:a 1 :b 2 :c 3})]
+    (eval-expr e)
+    ))


More simple feedback

More simple feedback

--- src/clj_simple_chart/ssb/data/ssb_fetch.clj
+++ src/clj_simple_chart/ssb/data/ssb_fetch.clj
@@ -19,11 +19,11 @@
   {:pre [(some #{code} (codes table))]}
   (let [v (variable table code)
         m (zipmap (:valueTexts v) (:values v))]
-    (assert (some #{valueText} (keys m)) (str "Must be one of: " (vec (sort (keys m)))))
+    (assert (some #{valueText} (keys m)) (str "Must be one of: " (vec (sort (keys m))) ", was: \"" valueText "\""))
     (get m valueText)))

 (defn filter-values [table code valueTexts]
-  (assert (some #{code} (codes table)) (str "Code must be one of: " (vec (codes table)) ", was " code))
+  (assert (some #{code} (codes table)) (str "Code must be one of: " (vec (codes table)) ", was: \"" code "\""))
   (cond (= "*" (first valueTexts))
         {:code code :selection {:filter "all" :values ["*"]}}
         :else {:code code :selection {:filter "item" :values (mapv (partial valueText->value table code) valueTexts)}}))
@@ -41,9 +41,9 @@
   (doseq [code (codes table)]
     (assert (some #{code} (map :code query-vector)) (str "Code " code " must be present in query vector!")))
   (let [query {:query query-vector :response {:format "csv"}}
-        resp (client/post (str "http://data.ssb.no/api/v0/no/table/" table) {:form-params query
+        resp (client/post (str "http://data.ssb.no/api/v0/no/table/" table) {:form-params  query
                                                                              :content-type :json
-                                                                             :as :byte-array})]
+                                                                             :as           :byte-array})]
     (assert (= "text/csv; charset=Windows-1252" (get-in resp [:headers "Content-Type"])))
     (let [body-str (String. (:body resp) "Windows-1252")]
       (csv/csv-map body-str))))


Cleanup

Cleanup

--- src/clojure/clojurewerkz/cassaforte/cql.clj
+++ src/clojure/clojurewerkz/cassaforte/cql.clj
@@ -142,10 +142,6 @@
   To specify additional clauses for a record (such as where or using), wrap that record
   and the clauses in a vector"
   [^Session session table records]
-  (println (new-query-api/batch
-               (apply
-                new-query-api/queries
-                (map #(new-query-api/insert table %) records))))
   (cc/execute session
               (new-query-api/batch
                (apply


Just fixing Dejo's github username :)

Just fixing Dejo's github username :)

--- src/clojureplayground/prime_numbers_fun.clj
+++ src/clojureplayground/prime_numbers_fun.clj
@@ -44,7 +44,7 @@
                                              (fn [ind value] (when (and (> ind 1) (true? value)) ind)) v))))))))

 (defn sieve-of-eratosthenes-revisited
-  "Based on a work by @paranoidtimes"
+  "Based on a work by @theparanoidtimes"
   [n]
   (let [erathostenes (transient (vec (replicate n true)))]
     (doseq [i (range 2 (Math/sqrt n))


Don't need to define build-workflow twice.

--- src/desdemona/workflows/sample_workflow.clj
+++ src/desdemona/workflows/sample_workflow.clj
@@ -3,8 +3,6 @@
 ;;; The workflow of an Onyx job describes the graph of all possible
 ;;; tasks that data can flow between.

-(defmulti build-workflow :mode)
-
 (defn build-workflow []
   [[:read-lines :extract-line-info]
    [:extract-line-info :prepare-rows]


add metro

add metro

--- ohack/src/ohack/core.clj
+++ ohack/src/ohack/core.clj
@@ -314,3 +314,5 @@
 ;; create an atom for our visualizer's play state
 (def vis-state (atom {:play-list (take 50 (parse-guitar-tab fast-car-tab))
                       :index 0}))
+;; this is a beat generator. it keeps ticking by the given timing
+(def metro (metronome 72))


add quil import

add quil import

--- ohack/src/ohack/core.clj
+++ ohack/src/ohack/core.clj
@@ -4,7 +4,9 @@
         [overtone.inst.sampled-piano]
         [overtone.synth.stringed])
   (:require [overtone.inst.synth :as synth]
-            [clojure.string :as s]))
+            [clojure.string :as s]
+            [quil.core :as q]
+            ))

 ;; run M-x cider-jack-in to get started
 ;;
@@ -299,3 +301,4 @@

 ;; let's now introduce quil and whip up a simple visualizater for the tab
+;; make sure you've added quil to the namespace


no need to stop/start es as it always happening

--- test/celestial/integration/es/systems.clj
+++ test/celestial/integration/es/systems.clj
@@ -19,15 +19,10 @@
   (sys/put "4" redis-prox-spec)
   )

-(defn initiliaze-es []
-  (sys/initialize)
-  (add-systems)
-  )
-
 (defn total [res] (get-in res [:hits :total]))

 (with-conf
-  (against-background [(before :contents (do (initiliaze-es) (set-user {:username "admin"} (populate-all)))) (after :contents (es/stop))]
+  (against-background [(before :contents (do (add-systems) (set-user {:username "admin"} (populate-all))))]

   (fact "basic system put and get" :integration :elasticsearch
     (get-in (sys/get "1") [:source :env]) => ":dev")


DM | 236 | Check that id_token is not included in token response when client credentials are invalid

--- test/stonecutter/test/controller/oauth.clj
+++ test/stonecutter/test/controller/oauth.clj
@@ -263,6 +263,7 @@

                         (:status response) => 400
                         response-body =not=> (contains {:access_token anything})
+                        response-body =not=> (contains {:id_token anything})
                         response-body =not=> (contains {:user-info anything}))))

          (facts "about openid connect"


temporary fix login

temporary fix login

--- src/mobile_patient/events.cljs
+++ src/mobile_patient/events.cljs
@@ -93,8 +93,9 @@
 (reg-event-fx
  :on-login
  (fn [{:keys [db]} [_ resp-body _ resp]]
-   (if resp.ok
-     (let [invalid (boolean (re-find #"Wrong credentials" resp-body))]
+   ;;(print (js/JSON.stringify resp))
+   ;;(if resp.ok
+     (let [invalid (boolean (re-find #"Wrong credentials" (str resp-body)))]
        (if invalid
          (ui/alert "" "Wrong credentials")
          (let [auth-data (-> (.-url resp) (str/split #"#") second h/query->params)
@@ -104,8 +105,10 @@
            (assert user-id)
            {:db (merge db {:access-token (:access_token auth-data)})
             :dispatch [:boot user-id]})))
-     (do
-       (ui/alert "Error" (str resp.status " " resp.statusText))))))
+     #_(do
+         (ui/alert "Error" (str resp.status " " resp.statusText)))
+   ;;  )
+   ))

 ;;
 ;; load-user


Cleanup function to check labels in an entry map.

--- src/oc/storage/api/entries.clj
+++ src/oc/storage/api/entries.clj
@@ -139,8 +139,14 @@
     (notification/send-trigger! (notification/->trigger :add org {:new created-board} author nil))
     created-board))

-(defn valid-labels-list? [entry-labels]
+(defn- valid-entry-labels? [entry-labels]
   (<= (count entry-labels) config/max-entry-labels))
+
+(defn- entry-labels-error [entry-labels]
+  (format "Too many labels (%d): %s. Max allowed is %d"
+          (count entry-labels)
+          (s/join " | " (map :name entry-labels))
+          config/max-entry-labels))

 (defn- valid-new-entry? [conn org-slug board-slug ctx]
   (let [org (org-res/get-org conn org-slug)
@@ -157,8 +163,8 @@
                         (create-publisher-board conn org author))]
     (cond (not board)
           [false, {:reason "Invalid board."}] ; couldn't find the specified board
-          (not (valid-labels-list? (:labels entry-map)))
-          [false, {:reason (format "Too many labels (%d): %s. Max allowed is %d" (count (:labels entry-map)) (s/join " | " (map :name (:labels entry-map))) config/max-entry-labels)}]
+          (not (valid-entry-labels? (:labels entry-map)))
+          [false, {:reason (entry-labels-error (:labels entry-map))}]
           :else
           (try
             ;; Create the new entry from the URL and data provided
@@ -239,8 +245,8 @@
                      {})]
       (cond (not (lib-schema/valid? common-res/Entry updated-entry))
             [false, {:updated-entry (api-common/rep updated-entry)}] ; invalid update
-            (not (valid-labels-list? (:labels entry-props)))
-            [false, {:reason (format "Too many labels (%d): %s. Max allowed is %d" (count (:labels entry-props)) (s/join " | " (map :name (:labels entry-props))) config/max-entry-labels)}]
+            (not (valid-entry-labels? (:labels entry-props)))
+            [false, {:reason (entry-labels-error (:labels entry-props))}]
             :else
             (merge ctx-base
                    {:existing-entry (api-common/rep existing-entry)


backpressure start/stop -> on/off

backpressure start/stop -> on/off

--- src/onyx/peer/virtual_peer.clj
+++ src/onyx/peer/virtual_peer.clj
@@ -78,10 +78,10 @@
       (let [ratio (/ (count buf) (.n buf))]
         (cond (and (not @on?) (> ratio high-water-ratio))
               (do (reset! on? true)
-                  (>!! outbox-ch (create-log-entry :backpressure-start {:peer id})))
+                  (>!! outbox-ch (create-log-entry :backpressure-on {:peer id})))
               (and @on? (< ratio low-water-ratio))
               (do (reset! on? false)
-                  (>!! outbox-ch (create-log-entry :backpressure-stop {:peer id})))))
+                  (>!! outbox-ch (create-log-entry :backpressure-off {:peer id})))))
       (Thread/sleep check-interval))))

 (defrecord VirtualPeer [opts]


Switch written key (schema error)

Switch written key (schema error)

--- src/onyx/plugin/bookkeeper.clj
+++ src/onyx/plugin/bookkeeper.clj
@@ -386,7 +386,7 @@
                                        callback-data))
                      (:leaves result))))
            (map list (:tree results) (:acks results))))
-    {:onyx.core/written? true})
+    {:bookkeeper/written? true})

   (seal-resource
     [_ _]


Improve flow conditions validation

Improve flow conditions validation

--- src/onyx/static/validation.clj
+++ src/onyx/static/validation.clj
@@ -168,19 +168,22 @@
     (schema/validate FlowCondition entry)))

 (defn validate-flow-connections [flow-schema workflow]
-  (let [all (into #{} (concat (map first workflow) (map second workflow)))]
-    (doseq [entry flow-schema]
-      (let [from (:flow/from entry)]
-        (when-not (or (some #{from} all) (= from :all))
-          (throw (ex-info ":flow/from value doesn't name a node in the workflow"
-                          {:entry entry}))))
-
-      (let [to (:flow/to entry)]
-        (when-not (or (= :all to)
-                      (= :none to)
-                      (clojure.set/subset? to all))
-          (throw (ex-info ":flow/to value doesn't name a node in the workflow, :all, or :none"
-                          {:entry entry})))))))
+  (let [task->egress-edges (reduce (fn [m [from to]]
+                                     (update m from (fn [v]
+                                                      (conj (set v) to))))
+                                   {}
+                                   workflow)
+        all-tasks (into (set (map first workflow)) (map second workflow))]
+    (doseq [{:keys [flow/from flow/to] :as entry} flow-schema]
+      (when-not (or (all-tasks from) (= from :all))
+        (throw (ex-info ":flow/from value doesn't name a node in the workflow"
+                        {:entry entry})))
+
+      (when-not (or (= :all to)
+                    (= :none to)
+                    (every? (fn [t] ((task->egress-edges from) t)) to))
+        (throw (ex-info ":flow/to value doesn't name a valid connected task in the workflow, :all, or :none"
+                        {:entry entry}))))))

 (defn validate-peer-config [peer-config]
   (schema/validate PeerConfig peer-config))


Use handler vars for routing

Use handler vars for routing

--- src/spam_and_eggs/http/app.clj
+++ src/spam_and_eggs/http/app.clj
@@ -4,6 +4,6 @@
             [spam-and-eggs.http.api :as api]
             [spam-and-eggs.http.html :as html]))

-(def handler (routes html/handler
-                     api/handler
+(def handler (routes #'html/handler
+                     #'api/handler
                      (route/not-found "Page not found")))


(PDB-4862) status-response: log error for multiple items

Check the expectation that there's only one item in the response, and
for now, just log an error if that's not true.

--- src/puppetlabs/puppetdb/http/handlers.clj
+++ src/puppetlabs/puppetdb/http/handlers.clj
@@ -1,5 +1,6 @@
 (ns puppetlabs.puppetdb.http.handlers
-  (:require [puppetlabs.puppetdb.http :as http]
+  (:require [clojure.tools.logging :as log]
+            [puppetlabs.puppetdb.http :as http]
             [bidi.schema :as bidi-schema]
             [puppetlabs.puppetdb.http.query :as http-q]
             [puppetlabs.puppetdb.query.paging :as paging]
@@ -73,9 +74,12 @@
   "Executes `query` and if a result is found, calls `found-fn` with
   that result, returns 404 otherwise."
   ([version query globals found-fn not-found-response query-params]
-   (if-let [query-result (first (stream-query-result version query query-params globals))]
-     (http/json-response (found-fn query-result))
-     not-found-response)))
+   (let [[item & items] (stream-query-result version query query-params globals)]
+     (when (seq items) ;; For now, just log
+       (log/error (trs "more than one item returned for singular query")))
+     (if item
+       (http/json-response (found-fn item))
+       not-found-response))))

 (defn catalog-status
   "Produces a response body for a request to retrieve the catalog for the node in route-params"


Cleanup.

Cleanup.

--- src/tryclojure/models/eval.clj
+++ src/tryclojure/models/eval.clj
@@ -9,7 +9,6 @@
   (:use [isla.interpreter])
   (:require [clojure.string :as str])
   (:require [isla.story :as story])
-  (:require [isla.utils :as utils])
   (:require [isla.library :as library])

   (:import java.io.File)
@@ -64,6 +63,4 @@
 (defmethod run-story-command :default [command expr] ;; normal command
   (if (nil? story)
     (throw (Exception. "Type 'hear --story--' to begin."))
-    (story/run-command story expr)))
-
-;; utils
+    (story/run-command story expr)))


[#4504] Sort assets alphabetically (send - asset)

Sort assets alphabetically (by symbol).
Keep ETH as first symbol in the list (like before), sort the rest
alphabetically.

--- src/status_im/ui/screens/wallet/subs.cljs
+++ src/status_im/ui/screens/wallet/subs.cljs
@@ -102,7 +102,7 @@
                   :<- [:wallet/visible-tokens-symbols]
                   (fn [[network visible-tokens-symbols]]
                     (conj (filter #(contains? visible-tokens-symbols (:symbol %))
-                                  (tokens/tokens-for (ethereum/network->chain-keyword network)))
+                                  (tokens/sorted-tokens-for (ethereum/network->chain-keyword network)))
                           tokens/ethereum)))

 (re-frame/reg-sub :wallet/visible-assets-with-amount


Quoting parameters

Quoting parameters

This allows us to compute strings given to arguments

--- lein-template/src/leiningen/new/modular.clj
+++ lein-template/src/leiningen/new/modular.clj
@@ -183,7 +183,7 @@
                                 {:key (make-key (:module a) n)
                                  :refers (conj (:refers instance) constructor)
                                  :constructor (symbol (clojure.core/name constructor))
-                                 :args (map #(cond (string? %) (str "\"" % "\"") :else %) args)
+                                 :args (map #(cond (string? %) % #_(str "\"" % "\"") :else %) args)

                                  ;; Construct 'using' here, not in template
                                  ;; it could be a map, it could be a vector


tooltip tweaks

tooltip tweaks

--- cljs-cheatsheet/cljs_cheatsheet/tooltips.cljs
+++ cljs-cheatsheet/cljs_cheatsheet/tooltips.cljs
@@ -119,7 +119,7 @@
         tooltip-height (.outerHeight $tooltip-el)
         tooltip-width (.outerWidth $tooltip-el)
         tooltip-left (- (+ link-x (half link-width)) (half tooltip-width))
-        tooltip-top (+ link-y link-height 4)]
+        tooltip-top (+ link-y link-height 5)]
     ;; position the el
     (.css $tooltip-el (js-obj
       "left" tooltip-left
@@ -127,12 +127,12 @@

     ;; save the bounds of the tooltip and link elements
     ;; NOTE: these numbers allow for a smidge of padding on the outside of the
-    ;; link element
+    ;; link element
     (reset! mousetrap-boxes {
       :link
-        {:x1 (- link-x 1)
+        {:x1 (dec link-x)
          :x2 (+ link-x link-width 2)
-         :y1 link-y
+         :y1 (dec link-y)
          :y2 (+ link-y link-height 20)} ;; let them mouse down into the tooltip

       :tooltip


Make the triangles a more sensible, so doesn't overlap.

--- src/videotest/triangles/triangle_core.clj
+++ src/videotest/triangles/triangle_core.clj
@@ -95,11 +95,12 @@
            blob-list))
      (q/pop-style))))

-(def MOSAIC-BIN-SIZE 12)
+(def MOSAIC-BIN-SIZE 16)
 (def MOSAIC-BIN-SIZE-X2 (* MOSAIC-BIN-SIZE 2.0))
 (def MOSAIC-BIN-SIZE-2 (/ MOSAIC-BIN-SIZE 2.0))
 (def NUM-COL-BINS (/ WIDTH  MOSAIC-BIN-SIZE))
 (def NUM-ROW-BINS (/ HEIGHT MOSAIC-BIN-SIZE))
+
 (def PI_2   (/ Math/PI 2.0))
 (def PI_3_2 (* 1.5 Math/PI))
 (def ORIENTATIONS [0 PI_2 Math/PI PI_3_2])
@@ -117,12 +118,22 @@
                    0                  MOSAIC-BIN-SIZE-X2
                    MOSAIC-BIN-SIZE-X2 MOSAIC-BIN-SIZE-X2)))))

+(defn gray-threshold [gray-mat mat-col mat-row]
+  (let [g (.get gray-mat mat-row mat-col)
+        g (if (< 0 (count g))
+            (first g)
+            0)]
+    (if (< 126 g)
+      g
+      0)))
+
 (defn draw-mosaic-pair [gray-mat [pt1 pt2]]
   (let [gray-fn (fn [mat-col mat-row]
                   (let [g (.get gray-mat mat-row mat-col)]
                     (if (< 0 (count g))
                       (first g)
                       0)))
+        ;gray-fn (partial gray-threshold gray-mat)
         [mat-col1 mat-row1] pt1
         [mat-col2 mat-row2] pt2
         g1 (gray-fn mat-col1 mat-row1)
@@ -144,7 +155,8 @@
                          :let [mat-col (+ (* col-bin MOSAIC-BIN-SIZE)
                                           MOSAIC-BIN-SIZE-2)
                                mat-row (+ (* row-bin MOSAIC-BIN-SIZE)
-                                          MOSAIC-BIN-SIZE-2)]]
+                                          MOSAIC-BIN-SIZE-2)]
+                         :when (= 0 (mod col-bin 2))]
                      [mat-col mat-row]))))
   (q/pop-style)
   (q/pop-matrix))


#6 Fixed tag filtering when multiple tags are provided

--- src/freecoin/handlers/transactions_list.clj
+++ src/freecoin/handlers/transactions_list.clj
@@ -42,6 +42,7 @@
   (cond
     (string? tags) #{tags}
     (set? tags)   tags
+    (coll? tags)  (into #{} tags)
     :else         #{}))

 (defn maybe-merge


Deleted debug output

Deleted debug output

So that we can add even more evil debug statements!

--- src/webapp/framework/server/systemfns.clj
+++ src/webapp/framework/server/systemfns.clj
@@ -313,9 +313,9 @@
 (defn    get-count    [db-table  where   params]

   (do
-    (println (str "db-table: " db-table))
-    (println (str "where: " where))
-    (println (str "params: " params))
+    ;(println (str "db-table: " db-table))
+    ;(println (str "where: " where))
+    ;(println (str "params: " params))

     (:cnt (sql-1 (str
                   "select count (id) as CNT from "
@@ -1140,7 +1140,7 @@

 (defn do-real [& {:keys [:table-name]}]
-  (println "-real**: table name: " table-name)
+  ;(println "-real**: table name: " table-name)

   (create-realtime-trigger  :table-name  (get-table-name  table-name)))

@@ -1202,7 +1202,7 @@
               ""))
         ]
     (do
-      (println "SQL::: " sql "," id , ":fields:" fields)
+      ;(println "SQL::: " sql "," id , ":fields:" fields)
       (sql-1  sql [id])
       )))

@@ -1217,10 +1217,10 @@

 (defn delete-record-from-realtime-update  [ table-name    record-id     data-session-id ]
   (do
-    (println (str "delete-record-from-realtime-update: " ))
-    (println (str "              table-name: "       table-name))
-    (println (str "              record-id: "        record-id))
-    (println (str "              data-session-id: "  data-session-id))
+    ;(println (str "delete-record-from-realtime-update: " ))
+    ;(println (str "              table-name: "       table-name))
+    ;(println (str "              record-id: "        record-id))
+    ;(println (str "              data-session-id: "  data-session-id))

   (let [client-data-atom         (if server-side-realtime-clients  (get @server-side-realtime-clients  data-session-id))
         response-atom            (if client-data-atom  client-data-atom )
@@ -1565,7 +1565,7 @@

 (defn parse-id [s]
   (do
-    (println (str "(defn parse-id [" s "]"))
+    ;(println (str "(defn parse-id [" s "]"))
     (let [find-num (re-find  #"\d+" s )]
       (if find-num
         (Integer. find-num)
@@ -1573,7 +1573,7 @@

 (defn get-id-type [ column-type ]
   (do
-    (println (str "*******COLTYPE:" column-type ":"))
+    ;(println (str "*******COLTYPE:" column-type ":"))
     (cond
     (= column-type "NUMBER")                       "INTEGER"
     (= column-type "integer")                      "INTEGER"
@@ -1601,8 +1601,8 @@
         db-table         (str (:record_table_name realtime-log-entry))
         db-schema        (str (:record_table_schema realtime-log-entry))
         ]
-    (println (str "**** Processing realtime record change: "))
-    (println (str "      schema.db-table: "  db-schema "." db-table))
+    ;(println (str "**** Processing realtime record change: "))
+    ;(println (str "      schema.db-table: "  db-schema "." db-table))
     ;(println (str "      "  "realtime-log-entry"))
     ;(println (str "      "  realtime-log-entry))
     ;(println (str "      "))
@@ -2048,8 +2048,8 @@
     ;(println (str "      " ))
     ;(println "SERVER: check-for-server-updates for client: " client-data-session-id)
     ;(println (str "      " (keys @server-side-realtime-clients)))
-    (println (str "      " (if client-data-atom  @client-data-atom)))
-    (println (str "      response: " (if response-atom  @(get @response-atom :update-request )  )))
+    ;(println (str "      " (if client-data-atom  @client-data-atom)))
+    ;(println (str "      response: " (if response-atom  @(get @response-atom :update-request )  )))
     (if response-atom
       @(get @response-atom :update-request )

@@ -2074,7 +2074,7 @@
                              (sql-1 "select  dbms_lob.substr( application_code, 3000, 1 ) as ac, dbms_lob.substr( application_code, 3000, 3001 ) as ac2 from appshare_applications where id = ?" [id]))
           content (str (get content-records :ac) (get content-records :ac2))
           ]
-      (println (str "id: " id))
+      ;(println (str "id: " id))
       {:value content})))


fix invalid pattern character 'Y'; SimpleDateFormat uses lowercase 'y'

--- src/leiningen/midje_doc/run/renderer.clj
+++ src/leiningen/midje_doc/run/renderer.clj
@@ -136,7 +136,7 @@
     (if-let [rev (:revision document)]
       [:h5 "Revision: v" rev])
     [:h5 "Date: " (.format
-                   (java.text.SimpleDateFormat. "dd MMMM YYYY")
+                   (java.text.SimpleDateFormat. "dd MMMM yyyy")
                    (java.util.Date.))]
     (if-let [url (:url document)]
       [:h5 "Website: " [:a {:href url} url]])


Use a real tmp file

Use a real tmp file

--- org-mode/src/com/gfredericks/org_agenda.clj
+++ org-mode/src/com/gfredericks/org_agenda.clj
@@ -350,22 +350,26 @@
 (defmacro with-atomic-write-to
   [cfg & body]
   `(let [cfg# ~cfg
+         tmp-file# (File/createTempFile "org-agenda-" ".tmp")
          out-file# (:agenda-file cfg#)]
-     (with-open [w# (io/writer "/tmp/w")
-                 pw# (java.io.PrintWriter. w#)]
-       (binding [*out* pw#]
-         (println (format "Written at %s" (java.time.Instant/now)))
-         (println)
-         ~@body
-         (print "\n\n")
-         (println (apply str (repeat 80 \;)))
-         (println ";; Postamble\n")
-         (println ";; Local Variables:")
-         (println ";; eval: (gfredericks-agenda-mode 1)")
-         (if-let [rf# (:refresh-file cfg#)]
-           (printf ";; gfredericks-agenda-mode-refresh-file: \"%s\"\n" rf#))
-         (println ";; End:"))
-       (clojure.java.shell/sh "mv" "/tmp/w" (str out-file#)))))
+     (try
+       (with-open [w# (io/writer tmp-file#)
+                   pw# (java.io.PrintWriter. w#)]
+         (binding [*out* pw#]
+           (println (format "Written at %s" (java.time.Instant/now)))
+           (println)
+           ~@body
+           (print "\n\n")
+           (println (apply str (repeat 80 \;)))
+           (println ";; Postamble\n")
+           (println ";; Local Variables:")
+           (println ";; eval: (gfredericks-agenda-mode 1)")
+           (if-let [rf# (:refresh-file cfg#)]
+             (printf ";; gfredericks-agenda-mode-refresh-file: \"%s\"\n" rf#))
+           (println ";; End:"))
+         (clojure.java.shell/sh "mv" (str tmp-file#) (str out-file#)))
+       (finally
+         (.delete tmp-file#)))))

 (defn write-to-agenda-file
   [deets-by-file {:keys [preamble] :as cfg}]


minor

minor

--- jar-prslib/test/clj/sixsq/slipstream/prs/javawrapper_test.clj
+++ jar-prslib/test/clj/sixsq/slipstream/prs/javawrapper_test.clj
@@ -32,7 +32,7 @@
   (is (= "module/application" (:uri (module-to-map (DeploymentModule. "application")))))
   )

-(deftest test-process-module
+(deftest test-process-module-compenent
   (let [m (process-module {:module (ImageModule. "component")
                            :foo    nil})]
     (is (contains? m :foo))
@@ -40,4 +40,7 @@
     (is (contains? (:module m) :uri))
     (is (contains? (:module m) :components))
     (is (= "module/component" (-> m :module :uri)))
-    ))+    ))
+
+(deftest test-process-module-application
+  )


Went back to a single worker.

Went back to a single worker.

--- tagcount/src/tagcount/core.clj
+++ tagcount/src/tagcount/core.clj
@@ -104,8 +104,6 @@
                         :processor process-records)]
       (info "Started worker" i "with uuid" uuid))))

-#_(amazonica.aws.kinesis/describe-stream cred "Twitter")
-
 (defn -main [& args]
-  (let [workers ((fnil #(Integer/parseInt %) "2") (first args))]
+  (let [workers ((fnil #(Integer/parseInt %) "1") (first args))]
     (start-workers workers)))


Do not return pins with entry on public access.

--- src/oc/storage/representations/entry.clj
+++ src/oc/storage/representations/entry.clj
@@ -213,12 +213,15 @@
                (poll-add-reply-link org-slug board-slug entry-uuid (:poll-uuid poll)))]))))
      (vals polls))))

-(defn- filter-pins [entry]
-  (if-not (= (:board-access entry) "private")
-    entry
-    (update entry
-            :pins
-            #(into {} (filter (fn [[k _]] (not= k (keyword config/seen-home-container-id))) %)))))
+(defn- filter-pins [entry member?]
+  (if member?
+    (if-not (= (:board-access entry) "private")
+      entry
+      (update entry
+              :pins
+              #(into {} (filter (fn [[k _]] (not= k (keyword config/seen-home-container-id))) %))))
+    ;; Remove pins for non members
+    (dissoc entry :pins)))

 (defn- entry-and-links
   "
@@ -329,7 +332,7 @@
           full-entry)
       (assoc :polls rendered-polls)
       (select-keys representation-props)
-      (filter-pins)
+      (filter-pins member?)
       (include-secure-uuid secure-uuid access-level)
       (include-interactions reaction-list :reactions)
       (include-interactions comment-list :comments)


Add some additional tests for key reading functions.

--- test/buddy/core/keys_tests.clj
+++ test/buddy/core/keys_tests.clj
@@ -14,39 +14,47 @@

 (ns buddy.core.keys-tests
   (:require [clojure.test :refer :all]
+            [clojure.java.io :as io]
             [buddy.core.codecs :refer :all]
-            [buddy.core.keys :refer :all]))
+            [buddy.core.keys :as keys]))

 (deftest rsa-dsa-keys-test
   (testing "Read rsa priv key"
-    (let [pkey (private-key "test/_files/privkey.3des.rsa.pem" "secret")]
+    (let [pkey (keys/private-key "test/_files/privkey.3des.rsa.pem" "secret")]
       (is (= (type pkey) org.bouncycastle.jcajce.provider.asymmetric.rsa.BCRSAPrivateCrtKey))))

   (testing "Read dsa priv key"
-    (let [pkey (private-key "test/_files/privkey.3des.dsa.pem" "secret")]
+    (let [pkey (keys/private-key "test/_files/privkey.3des.dsa.pem" "secret")]
       (is (= (type pkey) org.bouncycastle.jcajce.provider.asymmetric.dsa.BCDSAPrivateKey))))

   (testing "Read rsa priv key with bad password"
     (is (thrown? org.bouncycastle.openssl.EncryptionException
-                (private-key "test/_files/privkey.3des.rsa.pem" "secret2"))))
+                (keys/private-key "test/_files/privkey.3des.rsa.pem" "secret2"))))

   (testing "Read dsa priv key with bad password"
     (is (thrown? org.bouncycastle.openssl.EncryptionException
-                (private-key "test/_files/privkey.3des.dsa.pem" "secret2"))))
+                (keys/private-key "test/_files/privkey.3des.dsa.pem" "secret2"))))

   (testing "Read ecdsa priv key"
-    (let [pkey (private-key "test/_files/privkey.ecdsa.pem" "secret")]
-      (is (= (type pkey) org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey))))
+    (let [pkey (keys/private-key "test/_files/privkey.ecdsa.pem" "secret")]
+      (is (= (type pkey) org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey))
+      (is (keys/private-key? pkey))))

   (testing "Read rsa pub key"
-    (let [pkey (public-key "test/_files/pubkey.3des.rsa.pem")]
+    (let [pkey (keys/public-key "test/_files/pubkey.3des.rsa.pem")]
       (is (= (type pkey) org.bouncycastle.jcajce.provider.asymmetric.rsa.BCRSAPublicKey))))

   (testing "Read dsa pub key"
-    (let [pkey (public-key "test/_files/pubkey.3des.dsa.pem")]
-      (is (public-key? pkey))
+    (let [pkey (keys/public-key "test/_files/pubkey.3des.dsa.pem")]
+      (is (keys/public-key? pkey))
       (is (= (type pkey) org.bouncycastle.jcajce.provider.asymmetric.dsa.BCDSAPublicKey))))

   (testing "Read ec pub key"
-    (let [pkey (public-key "test/_files/pubkey.ecdsa.pem")]
-      (is (= (type pkey) org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey)))))
+    (let [pkey (keys/public-key "test/_files/pubkey.ecdsa.pem")]
+      (is (= (type pkey) org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey))))
+
+  (testing "Read public key from string."
+    (let [keystr (slurp "test/_files/pubkey.ecdsa.pem")
+          pkey (keys/str->public-key keystr)]
+      (is (= (type pkey) org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey))
+      (is (keys/public-key? pkey)))))


make sure test db is read only

make sure test db is read only

--- test/clojento/magento/t_db.clj
+++ test/clojento/magento/t_db.clj
@@ -48,12 +48,18 @@
   (log/info "completed tests with in-memory DB"))

+(def write-query (str
+                  "INSERT INTO `core_website` (`website_id`, `code`, `name`, `sort_order`, `default_group_id`, `is_default`, `is_staging`, `master_login`, `master_password`, `visibility`) "
+                  "VALUES (0, 'admin', 'Admin', 0, 0, 0, 0, '', '', '');"))
+
 ; TODO wrap in (facts ...), possibly?
 (with-state-changes [(before :contents (reset! system (fresh-system prepare-test-db db-config-ro)))
                      (after  :contents (component/stop @system))]
   (log/info "starting tests with read-only DB")
   (fact "migration table exists"
         (raw-jdbc-fetch (:db @system) "show tables;") => (contains {:table_name "ragtime_migrations", :table_schema "public"}))
-  (fact "migration table exists"
+  (fact "store table exists"
         (raw-jdbc-fetch (:db @system) "show tables;") => (contains {:table_name "core_store", :table_schema "public"}))
+  (fact "make sure db is read-only"
+        (raw-jdbc-execute (:db @system) write-query) => (throws org.h2.jdbc.JdbcBatchUpdateException #"read only"))
   (log/info "completed tests with read-only DB"))


Tap on return permits sign-in. Fixes #1285

--- src/status_im/accounts/login/screen.cljs
+++ src/status_im/accounts/login/screen.cljs
@@ -24,6 +24,10 @@

 (def password-text-input (atom nil))

+(defn login-account [password-text-input address password]
+  (.blur @password-text-input)
+  (dispatch [:login-account address password]))
+
 (defview login []
   [{:keys [address photo-path name password error processing]} [:get :login]]
   [view ast/accounts-container
@@ -40,13 +44,12 @@
                              :on-change-text    #(do
                                                    (dispatch [:set-in [:login :password] %])
                                                    (dispatch [:set-in [:login :error] ""]))
+                             :on-submit-editing #(login-account password-text-input address password)
                              :auto-focus        true
                              :secure-text-entry true
                              :error             (when (pos? (count error)) (i18n/label :t/wrong-password))}]]
     [view {:margin-top 16}
-     [touchable-highlight {:on-press #(do
-                                        (.blur @password-text-input)
-                                        (dispatch [:login-account address password]))}
+     [touchable-highlight {:on-press #(login-account password-text-input address password)}
       [view st/sign-in-button
        [text {:style st/sign-it-text} (i18n/label :t/sign-in)]]]]]
    (when processing


extend Realm classes with IEncodeClojure

--- src/status_im/data_store/realm/core.cljs
+++ src/status_im/data_store/realm/core.cljs
@@ -120,10 +120,67 @@
 (defn filtered [results filter-query]
   (.filtered results filter-query))

+(defn add-js->clj-array
+  "Extends type with IEncodeClojure and treats it as js array."
+  [t]
+  (extend-type t
+    IEncodeClojure
+    (-js->clj
+      ([x options]
+       (vec (map #(apply clj->js % options) x))))))
+
+(defn add-js->clj-object [t]
+  "Extends type with IEncodeClojure and treats it as js object."
+  (extend-type t
+    IEncodeClojure
+    (-js->clj
+      ([x options]
+       (let [{:keys [keywordize-keys]} options
+             keyfn (if keywordize-keys keyword str)]
+         (dissoc
+           (into
+             {}
+             (for [k (js-keys x)]
+               ;; ignore properties that are added with IEncodeClojure
+               (if (#{"cljs$core$IEncodeClojure$"
+                      "cljs$core$IEncodeClojure$_js__GT_clj$arity$2"}
+                     k)
+                 [nil nil]
+                 (let [v (aget x k)]
+                   ;; check if property is of List type and wasn't succesfully
+                   ;; transformed to ClojureScript data structure
+                   (when (and v
+                              (not (string? v))
+                              (not (boolean? v))
+                              (not (number? v))
+                              (not (coll? v))
+                              (not (satisfies? IEncodeClojure v))
+                              (str/includes? (type->str (type v)) "List"))
+                     (add-js->clj-object (type v)))
+                   [(keyfn k) (js->clj v :keywordize-keys keywordize-keys)]))))
+           nil))))))
+
+(defn check-collection
+  "Checks if collection was succesfully transformed to ClojureScript,
+   extends it with IEncodeClojure if necessary"
+  [coll]
+  (cond
+    (not (coll? coll))
+    (do (add-js->clj-array (type coll))
+        (check-collection (js->clj coll :keywordize-keys true)))
+
+    (let [f (first coll)]
+      (and f (not (map? f))))
+    (do (add-js->clj-object (type (first coll)))
+        (js->clj coll :keywordize-keys true))
+
+    :else coll))
+
 (defn realm-collection->list [collection]
   (-> collection
       (.map (fn [object _ _] object))
-      (js->clj :keywordize-keys true)))
+      (js->clj :keywordize-keys true)
+      check-collection))

 (defn list->array [record list-field]
   (update-in record [list-field] (comp vec vals)))
@@ -132,8 +189,12 @@
   (-> (aget result 0)))

 (defn single-cljs [result]
-  (some-> (aget result 0)
-          (js->clj :keywordize-keys true)))
+  (let [res (some-> (aget result 0)
+                    (js->clj :keywordize-keys true))]
+    (if (and res (not (map? res)))
+      (do (add-js->clj-object (type res))
+          (js->clj res :keywordize-keys true))
+      res)))

 (defn get-by-filter [realm schema-name filter]
   (-> realm
@@ -148,7 +209,7 @@

 (defn- field-type [realm schema-name field]
   (let [schema-by-name (get-schema-by-name (js->clj (.-schema realm) :keywordize-keys true))
-        field-def (get-in schema-by-name [schema-name :properties field])]
+        field-def      (get-in schema-by-name [schema-name :properties field])]
     (if (map? field-def)
       (:type field-def)
       field-def)))


fixed rendering typo

fixed rendering typo

--- src/untangled_spec/dom/edn_renderer.cljs
+++ src/untangled_spec/dom/edn_renderer.cljs
@@ -24,7 +24,7 @@
     s))

 (defn clearfix-separator* [s]
-  (dom/span {:key (get-key)}
+  (dom/span #js {:key (get-key)}
     (separator* s)
     (dom/span #js {:className "clearfix"})))

@@ -94,4 +94,4 @@
     (dom/div #js {:className "rendered-edn com-rigsomelight-devcards-typog"}
       (try
         (html (cond-> e diff (diff/patch diff)))
-        (catch Exception e (html "DIFF CRASHED ON OUTPUT"))))))
+        (catch js/Object e (html "DIFF CRASHED ON OUTPUT"))))))


[CS] Use destructured `data-specs` from fn args

--- src/vip/data_processor/validation/db.clj
+++ src/vip/data_processor/validation/db.clj
@@ -14,7 +14,7 @@
       ctx)))

 (defn validate-no-duplicated-rows [{:keys [data-specs] :as ctx}]
-  (reduce dupe-records/validate-no-duplicated-rows-in-table ctx (:data-specs ctx)))
+  (reduce dupe-records/validate-no-duplicated-rows-in-table ctx data-specs))

 (defn validate-one-record-limit [ctx]
   (record-limit/tables-allow-only-one-record ctx))


Add liquids gboe exploded data

Add liquids gboe exploded data

--- src/clj_simple_chart/ncs/johan_highlight_data.clj
+++ src/clj_simple_chart/ncs/johan_highlight_data.clj
@@ -82,6 +82,20 @@
     (reduce (fn [o [v flds]] (assoc o v (remaining-at-time flds yr :liquids)))
             {"YEAR" yr} cat-name-and-flds)))

+(defn explode-row [row]
+  (reduce (fn [o k]
+            (conj o {:year  (get row "YEAR")
+                     :c     k
+                     :value (get row k)}))
+          [] (mapv first cat-name-and-flds)))
+
+(def exploded-data-liquids-gboe
+  (->> flat-data-liquids
+       (mapcat explode-row)
+       (map #(update % :value (fn [v] (double (* 6.29e-3 v)))))
+       (sort-by :year)
+       (vec)))
+
 (csv/write-csv-format "data/ncs/discovery/johan-highlight.csv"
                       {:columns (vec (cons "YEAR" (mapv first cat-name-and-flds)))
                        :data    flat-data-liquids


Maps-canvas-dev changes

Maps-canvas-dev changes

--- src/cljs/gtfve/components/maps_canvas/google.cljs
+++ src/cljs/gtfve/components/maps_canvas/google.cljs
@@ -9,18 +9,24 @@
             [gtfve.utils.google-maps :as maps]
             [goog.events :as gevents]))

-(defn maps-canvas-dev [ui _]
+(defn maps-canvas-dev [data _]
   (reify
+    om/IDisplayName (display-name [_] "Maps Canvas Dev")
     om/IRenderState
     (render-state [_ {:keys [gmap] :as state}]
       (html
        [:div.panel.panel-info {:style {:position "fixed"
                                        :bottom "10px"
-                                       :right "10px"}}
+                                       :right "10px"
+                                       :z-index "10000"}}
         [:div.panel-heading "Map Info"]
         [:div.panel-body
          (when gmap
-           [:p (pr-str (:bounds state))])]]))))
+           [:div
+            [:p (pr-str (js->clj (.getBounds gmap)))]
+            [:p (count data) (pr-str [(:stop/latitude (last data))
+                                      (:stop/longitude (last data))])]])]]))))
+

 (defn search-stop-marker [data owner]
   (reify


Fix docstring for -service

Fix docstring for -service

--- ex2b/src/ex2b/theServlet.clj
+++ ex2b/src/ex2b/theServlet.clj
@@ -14,7 +14,11 @@
 ;; ring-servlet)

 (defn -service
-  ^{:doc "Servlet service method.  Call ring servlet adapter code to convert incoming HttpServletRequest POJO to a Clojure map, then call our handler implementation that generates the output map, then call another ring adapter to convert that Clojure map to the outgoing HttpServletResponse POJO."}
+  ^{:doc "Servlet service method.  Call ring servlet adapter code to
+  convert incoming HttpServletRequest POJO to a Clojure map, then call
+  our handler implementation that generates the output map, then call
+  another ring adapter to convert that Clojure map to the outgoing
+  HttpServletResponse POJO."}
   [^HttpServlet this
    ^HttpServletRequest rqst
    ^HttpServletRequest resp]


Get info about configurated devices

Get info about configurated devices


Move make-service out of service method (fixes #166)

--- ring-servlet/src/ring/util/servlet.clj
+++ ring-servlet/src/ring/util/servlet.clj
@@ -131,10 +131,10 @@
 (defn servlet
   "Create a servlet from a Ring handler."
   [handler]
-  (proxy [HttpServlet] []
-    (service [request response]
-      ((make-service-method handler)
-         this request response))))
+  (let [service-method (make-service-method handler)]
+    (proxy [HttpServlet] []
+      (service [request response]
+        (service-method this request response)))))

 (defmacro defservice
   "Defines a service method with an optional prefix suitable for being used by
@@ -147,7 +147,7 @@
   ([handler]
    `(defservice "-" ~handler))
   ([prefix handler]
-   `(defn ~(symbol (str prefix "service"))
-      [servlet# request# response#]
-      ((make-service-method ~handler)
-         servlet# request# response#))))
+   `(let [service-method# (make-service-method ~handler)]
+      (defn ~(symbol (str prefix "service"))
+        [servlet# request# response#]
+        (service-method# servlet# request# response#)))))


Refactor benchmarks.

Refactor benchmarks.

--- test/benchmark_test/method_call_tests.clj
+++ test/benchmark_test/method_call_tests.clj
@@ -15,6 +15,16 @@
   (println "\nRunning: condp-benchmark-0")
   (let [f (fn [arg]
             (condp = arg
+              (str arg)))]
+    (cc/with-progress-reporting
+      (cc/quick-bench
+        (f "bar")
+        :verbose))))
+
+(deftest condp-benchmark-1
+  (println "\nRunning: condp-benchmark-1")
+  (let [f (fn [arg]
+            (condp = arg
               :foo_0 0
               (str arg)))]
     (cc/with-progress-reporting
@@ -22,8 +32,8 @@
         (f "bar")
         :verbose))))

-(deftest condp-benchmark-1
-  (println "\nRunning: condp-benchmark-1")
+(deftest condp-benchmark-2
+  (println "\nRunning: condp-benchmark-2")
   (let [f (fn [arg]
             (condp = arg
               :foo_0 0
@@ -42,8 +52,8 @@
         (f "bar")
         :verbose))))

-(deftest condp-benchmark-2
-  (println "\nRunning: condp-benchmark-2")
+(deftest condp-benchmark-3
+  (println "\nRunning: condp-benchmark-3")
   (let [f (fn [arg]
             (condp = arg
               :foo_0 0
@@ -72,8 +82,8 @@
         (f "bar")
         :verbose))))

-(deftest condp-benchmark-3
-  (println "\nRunning: condp-benchmark-3")
+(deftest condp-benchmark-4
+  (println "\nRunning: condp-benchmark-4")
   (let [f (fn [arg]
             (condp = arg
               :foo_0 0
@@ -112,8 +122,8 @@
         (f "bar")
         :verbose))))

-(deftest condp-benchmark-4
-  (println "\nRunning: condp-benchmark-4")
+(deftest condp-benchmark-5
+  (println "\nRunning: condp-benchmark-5")
   (let [f (fn [arg]
             (condp = arg
               :foo_0 0
@@ -215,8 +225,7 @@

 (deftest map-benchmark-0
   (println "\nRunning: map-benchmark-0")
-  (let [m {:foo_0 0
-           :bar (fn [arg] (str arg))}]
+  (let [m {:bar (fn [arg] (str arg))}]
     (cc/with-progress-reporting
       (cc/quick-bench
         ((m :bar) "bar")
@@ -225,15 +234,6 @@
 (deftest map-benchmark-1
   (println "\nRunning: map-benchmark-1")
   (let [m {:foo_0 0
-           :foo_1 1
-           :foo_2 2
-           :foo_3 3
-           :foo_4 4
-           :foo_5 5
-           :foo_6 6
-           :foo_7 7
-           :foo_8 8
-           :foo_9 9
            :bar (fn [arg] (str arg))}]
     (cc/with-progress-reporting
       (cc/quick-bench
@@ -242,6 +242,24 @@

 (deftest map-benchmark-2
   (println "\nRunning: map-benchmark-2")
+  (let [m {:foo_0 0
+           :foo_1 1
+           :foo_2 2
+           :foo_3 3
+           :foo_4 4
+           :foo_5 5
+           :foo_6 6
+           :foo_7 7
+           :foo_8 8
+           :foo_9 9
+           :bar (fn [arg] (str arg))}]
+    (cc/with-progress-reporting
+      (cc/quick-bench
+        ((m :bar) "bar")
+        :verbose))))
+
+(deftest map-benchmark-3
+  (println "\nRunning: map-benchmark-3")
   (let [m {:foo_0 0
            :foo_1 1
            :foo_2 2
@@ -268,8 +286,8 @@
         ((m :bar) "bar")
         :verbose))))

-(deftest map-benchmark-3
-  (println "\nRunning: map-benchmark-3")
+(deftest map-benchmark-4
+  (println "\nRunning: map-benchmark-4")
   (let [m {:foo_0 0
            :foo_1 1
            :foo_2 2
@@ -306,8 +324,8 @@
         ((m :bar) "bar")
         :verbose))))

-(deftest map-benchmark-4
-  (println "\nRunning: map-benchmark-4")
+(deftest map-benchmark-5
+  (println "\nRunning: map-benchmark-5")
   (let [m {:foo_0 0
            :foo_1 1
            :foo_2 2
@@ -405,8 +423,7 @@

 (deftest map-rev-benchmark-0
   (println "\nRunning: map-rev-benchmark-0")
-  (let [m {:foo_0 0
-           :bar (fn [arg] (str arg))}]
+  (let [m {:bar (fn [arg] (str arg))}]
     (cc/with-progress-reporting
       (cc/quick-bench
         ((:bar m) "bar")
@@ -415,15 +432,6 @@
 (deftest map-rev-benchmark-1
   (println "\nRunning: map-rev-benchmark-1")
   (let [m {:foo_0 0
-           :foo_1 1
-           :foo_2 2
-           :foo_3 3
-           :foo_4 4
-           :foo_5 5
-           :foo_6 6
-           :foo_7 7
-           :foo_8 8
-           :foo_9 9
            :bar (fn [arg] (str arg))}]
     (cc/with-progress-reporting
       (cc/quick-bench
@@ -432,6 +440,24 @@

 (deftest map-rev-benchmark-2
   (println "\nRunning: map-rev-benchmark-2")
+  (let [m {:foo_0 0
+           :foo_1 1
+           :foo_2 2
+           :foo_3 3
+           :foo_4 4
+           :foo_5 5
+           :foo_6 6
+           :foo_7 7
+           :foo_8 8
+           :foo_9 9
+           :bar (fn [arg] (str arg))}]
+    (cc/with-progress-reporting
+      (cc/quick-bench
+        ((:bar m) "bar")
+        :verbose))))
+
+(deftest map-rev-benchmark-3
+  (println "\nRunning: map-rev-benchmark-3")
   (let [m {:foo_0 0
            :foo_1 1
            :foo_2 2
@@ -458,8 +484,8 @@
         ((:bar m) "bar")
         :verbose))))

-(deftest map-rev-benchmark-3
-  (println "\nRunning: map-rev-benchmark-3")
+(deftest map-rev-benchmark-4
+  (println "\nRunning: map-rev-benchmark-4")
   (let [m {:foo_0 0
            :foo_1 1
            :foo_2 2
@@ -496,8 +522,8 @@
         ((:bar m) "bar")
         :verbose))))

-(deftest map-rev-benchmark-4
-  (println "\nRunning: map-rev-benchmark-4")
+(deftest map-rev-benchmark-5
+  (println "\nRunning: map-rev-benchmark-5")
   (let [m {:foo_0 0
            :foo_1 1
            :foo_2 2
@@ -576,9 +602,3 @@
         (.bar t "bar")
         :verbose))))

-;(deftest benchmark-1
-;  (cc/report-result
-;    (cc/quick-benchmark
-;      (Thread/sleep 10)
-;      {:verbose true})))
-


Different names to avoid warnings

Different names to avoid warnings

--- test/com/wsscode/pathom/connect_test.cljc
+++ test/com/wsscode/pathom/connect_test.cljc
@@ -872,19 +872,19 @@

 (def pindexes (atom {}))

-(defmulti resolver-fn pc/resolver-dispatch)
-(def defresolver (pc/resolver-factory resolver-fn pindexes))
-
-(defresolver 'a
+(defmulti resolver-fn-p pc/resolver-dispatch)
+(def defresolver-p (pc/resolver-factory resolver-fn-p pindexes))
+
+(defresolver-p 'a
   {::pc/output [:a]}
   (fn [_ _] {:a 1}))

-(defresolver 'a->b
+(defresolver-p 'a->b
   {::pc/input  #{:a}
    ::pc/output [:b]}
   (fn [_ {:keys [a]}] {:b (+ a 10)}))

-(defresolver 'coisas
+(defresolver-p 'coisas
   {::pc/output [{:c [:i]}]}
   (fn [_ _]
     {:c [{:i 1} {:i 2} {:i 3}]}))
@@ -894,7 +894,7 @@
    2 "b"
    3 "c"})

-(defresolver 'i->l
+(defresolver-p 'i->l
   {::pc/input  #{:i}
    ::pc/output [:l]
    ::pc/batch? true}
@@ -904,25 +904,25 @@
     (fn [_ i-values]
       (mapv #(hash-map :l (get i->l (:i %))) i-values))))

-(defresolver 'error
+(defresolver-p 'error
   {::pc/output [:error]}
   (fn [_ _]
     (throw (ex-info "Error" {}))))

-(defresolver 'error-batch
+(defresolver-p 'error-batch
   {::pc/input  #{:i}
    ::pc/output [:error-batch]
    ::pc/batch? true}
   (fn [_ _]
     (throw (ex-info "Error" {}))))

-(defresolver 'error->d
+(defresolver-p 'error->d
   {::pc/input  #{:error}
    ::pc/output [:d]}
   (fn [_ _]
     {:d 3}))

-(defresolver 'invalid
+(defresolver-p 'invalid
   {::pc/output [:invalid]}
   (fn [_ _]
     42))
@@ -931,7 +931,7 @@

 (defn parallel-env-base []
   {::pc/indexes           @pindexes
-   ::pc/resolver-dispatch resolver-fn
+   ::pc/resolver-dispatch resolver-fn-p
    ::pt/trace*            trace
    ::p/entity             (atom {})
    ::pp/key-watchers      (atom {})
@@ -940,25 +940,19 @@
 (defn parallel-env [key]
   (assoc (parallel-env-base) :ast (p/query->ast1 [key])))

-(defn call-parallel-reader [env key]
-  (reset! trace [])
-  (let [res (pc/parallel-reader (merge (parallel-env key) {::p/path [key]} env))]
-    (if (::pp/response-stream res)
-      (update res ::pp/response-stream (fn [x] (async/<!! (async/into [] x))))
-      res)))
+#?(:clj
+   (defn call-parallel-reader [env key]
+     (reset! trace [])
+     (let [res (pc/parallel-reader (merge (parallel-env key) {::p/path [key]} env))]
+       (if (::pp/response-stream res)
+         (update res ::pp/response-stream (fn [x] (async/<!! (async/into [] x))))
+         res))))

 (defn comparable-trace [trace]
   (mapv #(dissoc % ::pt/timestamp ::pt/id) trace))

 (defn comparable-trace-in-any-order [trace]
   (frequencies (comparable-trace trace)))
-
-(comment
-  (pc/parallel-reader (assoc (parallel-env :b)
-                        ::p/errors* (atom {})
-                        ::p/entity  (atom {:a ::p/reader-error})))
-  (call-parallel-reader {::p/errors* (atom {})
-                         ::p/entity  (atom {:a ::p/reader-error})} :b))

 #?(:clj
    (deftest test-parallel


Add find-item-group and find-item forms

Add find-item-group and find-item forms

--- src/lens/routes.clj
+++ src/lens/routes.clj
@@ -43,6 +43,18 @@
       :params
       {:id
        {:type :string}}}
+     :lens/find-item-group
+     {:action "/find-item-group"
+      :method "GET"
+      :params
+      {:id
+       {:type :string}}}
+     :lens/find-item
+     {:action "/find-item"
+      :method "GET"
+      :params
+      {:id
+       {:type :string}}}
      :lens/query
      {:action "/query"
       :method "GET"
@@ -346,6 +358,20 @@
        (->> (api/items item-group)
             (sort-by :item/rank)
             (render-embedded-items (timeout 100)))}})
+    (ring-resp/not-found
+     {:links {:up {:href "/forms"}}
+      :error "Item group not found."})))
+
+(defn item-group-bare [db id]
+  (if-let [item-group (api/item-group db id)]
+    (ring-resp/response
+     {:id (:item-group/id item-group)
+      :name (:name item-group)
+      :type :item-group
+      :links
+      {:up {:href (str "/forms/" (:form/id (:item-group/form item-group)))
+            :title (:name (:item-group/form item-group))}
+       :self {:href (str "/item-groups/" id)}}})
     (ring-resp/not-found
      {:links {:up {:href "/forms"}}
       :error "Item group not found."})))
@@ -560,12 +586,16 @@

    (GET "/item-groups/:id" [db id] (item-group db id))

+   (GET "/find-item-group" [db id] (item-group-bare db id))
+
    (GET "/item-groups/:id/count" [db id] (item-group-count db id))

    (GET "/item-groups/:id/search-items" [db id query]
          (search-items db id query))

    (GET "/items/:id" [db id] (item db id))
+
+   (GET "/find-item" [db id] (item db id))

    (GET "/items/:id/count" [db id] (item-count db id))


satellite-master:  Return more info in black hole eval events.

When logged/emailed, the events will now contain the actual task
fail/start/finish numbers.

--- satellite-master/src/satellite/recipes.clj
+++ satellite-master/src/satellite/recipes.clj
@@ -15,6 +15,7 @@
 (ns satellite.recipes
   (:require
    [clojure.tools.logging :refer :all]
+   [riemann.common :refer [event]]
    [riemann.streams :refer :all]
    [riemann.folds :as folds]
    [satellite.whitelist :as whitelist]))
@@ -135,14 +136,18 @@
   returns a single event which indicates whether the host seems to be a black hole,
   using :state ok or critical"
   [settings [failed started finished]]
-  (assoc failed
-         :service "task blackhole detected"
-         :state (if (and (exceeds-threshold? failed started
-                                             (:blackhole-fails-to-starts-threshold settings))
-                         (exceeds-threshold? failed finished
-                                             (:blackhole-fails-to-finishes-threshold settings)))
-                  "critical" "ok")
-         :description "Whether the host represents a black hole for tasks."
-         :metric nil
-         :tags nil))
+  (event {:host (:host failed)
+          :service "task blackhole detected"
+          :ttl (:ttl failed)
+          :state (if (and (exceeds-threshold? failed started
+                                              (:blackhole-fails-to-starts-threshold settings))
+                          (exceeds-threshold? failed finished
+                                              (:blackhole-fails-to-finishes-threshold settings)))
+                   "critical" "ok")
+          :description "Whether the host represents a black hole for tasks."
+          :failed (:metric failed)
+          :finished (:metric finished)
+          :started (:metric started)
+          :metric nil
+          :tags nil}))