Move tests

Move tests

--- test/com/wsscode/pathom/connect/run_graph_test.cljc
+++ test/com/wsscode/pathom/connect/run_graph_test.cljc
@@ -89,227 +89,6 @@

       render-graphviz?
       (render-graph env))))
-
-(deftest test-compute-root-or
-  (testing "set root when no root is the current"
-    (is (= (pcrg/compute-root-or
-             {::pcrg/provides {:a {}}
-              ::pcrg/requires {:a {}}
-              ::pcrg/nodes    {1 {::pcrg/node-id  1
-                                  ::pc/sym        'a
-                                  ::pcrg/requires {:a {}}
-                                  ::pcrg/provides {:a {}}}}}
-             (base-graph-env)
-             {::pcrg/node-id 1})
-           {::pcrg/provides {:a {}}
-            ::pcrg/requires {:a {}}
-            ::pcrg/root     1
-            ::pcrg/nodes    {1 {::pcrg/node-id  1
-                                ::pc/sym        'a
-                                ::pcrg/requires {:a {}}
-                                ::pcrg/provides {:a {}}}}})))
-
-  (testing "create new or runner"
-    (is (= (pcrg/compute-root-or
-             {::pcrg/provides {:a {}}
-              ::pcrg/requires {:a {}}
-              ::pcrg/root     1
-              ::pcrg/nodes    {1 {::pcrg/node-id  1
-                                  ::pc/sym        'a
-                                  ::pcrg/requires {:a {}}
-                                  ::pcrg/provides {:a {}}}
-                               2 {::pcrg/node-id  2
-                                  ::pc/sym        'a2
-                                  ::pcrg/requires {:a {}}
-                                  ::pcrg/provides {:a {}}}}}
-             (assoc (base-graph-env) ::pcrg/id-counter (atom 2)
-               ::pc/attribute :a)
-             {::pcrg/node-id 2})
-           {::pcrg/provides {:a {}}
-            ::pcrg/requires {:a {}}
-            ::pcrg/root     3
-            ::pcrg/nodes    {1 {::pcrg/node-id    1
-                                ::pcrg/after-node 3
-                                ::pc/sym          'a
-                                ::pcrg/requires   {:a {}}
-                                ::pcrg/provides   {:a {}}}
-                             2 {::pcrg/node-id    2
-                                ::pcrg/after-node 3
-                                ::pc/sym          'a2
-                                ::pcrg/requires   {:a {}}
-                                ::pcrg/provides   {:a {}}}
-                             3 {::pcrg/node-id  3
-                                ::pcrg/provides {:a {}}
-                                ::pcrg/run-or   [1 2]
-                                ::pcrg/requires {:a {}}}}}))
-
-    (testing "with run-next"
-      (is (= (pcrg/compute-root-or
-               {::pcrg/provides {:a {}}
-                ::pcrg/requires {:a {}}
-                ::pcrg/root     2
-                ::pcrg/nodes    {2 {::pcrg/node-id  2
-                                    ::pc/sym        'a
-                                    ::pcrg/requires {:a {}}
-                                    ::pcrg/provides {:a {}}
-                                    ::pcrg/run-next 1}
-                                 3 {::pcrg/node-id  3
-                                    ::pc/sym        'a2
-                                    ::pcrg/requires {:a {}}
-                                    ::pcrg/provides {:a {}}
-                                    ::pcrg/run-next 1}}}
-               (assoc (base-graph-env) ::pcrg/id-counter (atom 3)
-                 ::pc/attribute :a
-                 ::pc/index-resolvers {'a  {::pc/provides {:a {}}}
-                                       'a2 {::pc/provides {:a {}}}})
-               {::pcrg/node-id 3})
-             {::pcrg/provides {:a {}}
-              ::pcrg/requires {:a {}}
-              ::pcrg/root     4
-              ::pcrg/nodes    {1 {::pcrg/after-node 4}
-                               2 {::pcrg/node-id    2
-                                  ::pc/sym          'a
-                                  ::pcrg/after-node 4
-                                  ::pcrg/requires   {:a {}}
-                                  ::pcrg/provides   {:a {}}}
-                               3 {::pcrg/node-id    3
-                                  ::pcrg/after-node 4
-                                  ::pc/sym          'a2
-                                  ::pcrg/requires   {:a {}}
-                                  ::pcrg/provides   {:a {}}}
-                               4 {::pcrg/node-id  4
-                                  ::pcrg/run-or   [2 3]
-                                  ::pcrg/requires {:a {}}
-                                  ::pcrg/provides {:a {}}
-                                  ::pcrg/run-next 1}}}))
-
-      (testing "don't optimize when run next is different"
-        (is (= (pcrg/compute-root-or
-                 {::pcrg/provides {:a {}}
-                  ::pcrg/requires {:a {}}
-                  ::pcrg/root     2
-                  ::pcrg/nodes    {2 {::pcrg/node-id  2
-                                      ::pc/sym        'a
-                                      ::pcrg/requires {:a {}}
-                                      ::pcrg/provides {:a {}}
-                                      ::pcrg/run-next 1}
-                                   3 {::pcrg/node-id  3
-                                      ::pc/sym        'a2
-                                      ::pcrg/requires {:a {}}
-                                      ::pcrg/provides {:a {}}
-                                      ::pcrg/run-next 10}}}
-                 (assoc (base-graph-env) ::pcrg/id-counter (atom 3)
-                   ::pc/attribute :a)
-                 {::pcrg/node-id 3})
-               {::pcrg/provides {:a {}}
-                ::pcrg/requires {:a {}}
-                ::pcrg/root     4
-                ::pcrg/nodes    {2 {::pcrg/node-id    2
-                                    ::pcrg/after-node 4
-                                    ::pc/sym          'a
-                                    ::pcrg/requires   {:a {}}
-                                    ::pcrg/provides   {:a {}}
-                                    ::pcrg/run-next   1}
-                                 3 {::pcrg/node-id    3
-                                    ::pcrg/after-node 4
-                                    ::pc/sym          'a2
-                                    ::pcrg/requires   {:a {}}
-                                    ::pcrg/provides   {:a {}}
-                                    ::pcrg/run-next   10}
-                                 4 {::pcrg/node-id  4
-                                    ::pcrg/run-or   [2 3]
-                                    ::pcrg/provides {:a {}}
-                                    ::pcrg/requires {:a {}}}}})))))
-
-  (testing "add to the runner"
-    (is (= (pcrg/compute-root-or
-             {::pcrg/provides {:a {}}
-              ::pcrg/requires {:a {}}
-              ::pcrg/root     3
-              ::pcrg/nodes    {1 {::pcrg/node-id  1
-                                  ::pc/sym        'a
-                                  ::pcrg/requires {:a {}}
-                                  ::pcrg/provides {:a {}}}
-                               2 {::pcrg/node-id  2
-                                  ::pc/sym        'a2
-                                  ::pcrg/requires {:a {}}
-                                  ::pcrg/provides {:a {}}}
-                               3 {::pcrg/node-id  3
-                                  ::pcrg/run-or   [1 2]
-                                  ::pcrg/requires {:a {}}}
-                               4 {::pcrg/node-id  4
-                                  ::pc/sym        'a3
-                                  ::pcrg/requires {:a {}}
-                                  ::pcrg/provides {:a {}}}}}
-             (base-graph-env)
-             {::pcrg/node-id 4})
-           {::pcrg/provides {:a {}}
-            ::pcrg/requires {:a {}}
-            ::pcrg/root     3
-            ::pcrg/nodes    {1 {::pcrg/node-id  1
-                                ::pc/sym        'a
-                                ::pcrg/requires {:a {}}
-                                ::pcrg/provides {:a {}}}
-                             2 {::pcrg/node-id  2
-                                ::pc/sym        'a2
-                                ::pcrg/requires {:a {}}
-                                ::pcrg/provides {:a {}}}
-                             3 {::pcrg/node-id  3
-                                ::pcrg/provides {:a {}}
-                                ::pcrg/run-or   [1 2 4]
-                                ::pcrg/requires {:a {}}}
-                             4 {::pcrg/node-id    4
-                                ::pcrg/after-node 3
-                                ::pc/sym          'a3
-                                ::pcrg/requires   {:a {}}
-                                ::pcrg/provides   {:a {}}}}}))
-
-    (testing "with run context"
-      (is (= (pcrg/compute-root-or
-               {::pcrg/provides {:a {}}
-                ::pcrg/requires {:a {}}
-                ::pcrg/root     3
-                ::pcrg/nodes    {1 {::pcrg/node-id  1
-                                    ::pc/sym        'a
-                                    ::pcrg/requires {:a {}}
-                                    ::pcrg/provides {:a {}}}
-                                 2 {::pcrg/node-id  2
-                                    ::pc/sym        'a2
-                                    ::pcrg/requires {:a {}}
-                                    ::pcrg/provides {:a {}}}
-                                 3 {::pcrg/node-id  3
-                                    ::pcrg/run-or   [1 2]
-                                    ::pcrg/requires {:a {}}
-                                    ::pcrg/run-next 10}
-                                 4 {::pcrg/node-id  4
-                                    ::pc/sym        'a3
-                                    ::pcrg/requires {:a {}}
-                                    ::pcrg/provides {:a {}}
-                                    ::pcrg/run-next 10}}}
-               (assoc (base-graph-env)
-                 ::pc/index-resolvers {'a3 {::pc/provides {:a {}}}})
-               {::pcrg/node-id 4})
-             {::pcrg/provides {:a {}}
-              ::pcrg/requires {:a {}}
-              ::pcrg/root     3
-              ::pcrg/nodes    {1 {::pcrg/node-id  1
-                                  ::pc/sym        'a
-                                  ::pcrg/requires {:a {}}
-                                  ::pcrg/provides {:a {}}}
-                               2 {::pcrg/node-id  2
-                                  ::pc/sym        'a2
-                                  ::pcrg/requires {:a {}}
-                                  ::pcrg/provides {:a {}}}
-                               3 {::pcrg/node-id  3
-                                  ::pcrg/provides {:a {}}
-                                  ::pcrg/run-or   [1 2 4]
-                                  ::pcrg/requires {:a {}}
-                                  ::pcrg/run-next 10}
-                               4 {::pcrg/node-id    4
-                                  ::pcrg/after-node 3
-                                  ::pc/sym          'a3
-                                  ::pcrg/requires   {:a {}}
-                                  ::pcrg/provides   {:a {}}}}})))))

 (deftest compute-run-graph-test
   (testing "no path"
@@ -1557,7 +1336,7 @@
                                                            ::pc/dynamic-resolver? true
                                                            ::pc/resolve           (fn [_ _])}}
                   ::resolvers          [{::pc/sym    'b
-                                         ::pc/input #{:a}
+                                         ::pc/input  #{:a}
                                          ::pc/output [:b]}]
                   ::pc/index-oir       {:a {#{} #{'dynamic-resolver}}
                                         :c {#{:b} #{'dynamic-resolver}}}
@@ -1648,6 +1427,249 @@
                     :extended-nodes    #{2}
                     :root              2}))))

+(deftest test-compute-root-or
+  (testing "set root when no root is the current"
+    (is (= (pcrg/compute-root-or
+             {::pcrg/provides {:a {}}
+              ::pcrg/requires {:a {}}
+              ::pcrg/nodes    {1 {::pcrg/node-id  1
+                                  ::pc/sym        'a
+                                  ::pcrg/requires {:a {}}
+                                  ::pcrg/provides {:a {}}}}}
+             (base-graph-env)
+             {::pcrg/node-id 1})
+           {::pcrg/provides {:a {}}
+            ::pcrg/requires {:a {}}
+            ::pcrg/root     1
+            ::pcrg/nodes    {1 {::pcrg/node-id  1
+                                ::pc/sym        'a
+                                ::pcrg/requires {:a {}}
+                                ::pcrg/provides {:a {}}}}})))
+
+  (testing "create new or runner"
+    (is (= (pcrg/compute-root-or
+             {::pcrg/provides {:a {}}
+              ::pcrg/requires {:a {}}
+              ::pcrg/root     1
+              ::pcrg/nodes    {1 {::pcrg/node-id  1
+                                  ::pc/sym        'a
+                                  ::pcrg/requires {:a {}}
+                                  ::pcrg/provides {:a {}}}
+                               2 {::pcrg/node-id  2
+                                  ::pc/sym        'a2
+                                  ::pcrg/requires {:a {}}
+                                  ::pcrg/provides {:a {}}}}}
+             (assoc (base-graph-env) ::pcrg/id-counter (atom 2)
+               ::pc/attribute :a)
+             {::pcrg/node-id 2})
+           {::pcrg/provides {:a {}}
+            ::pcrg/requires {:a {}}
+            ::pcrg/root     3
+            ::pcrg/nodes    {1 {::pcrg/node-id    1
+                                ::pcrg/after-node 3
+                                ::pc/sym          'a
+                                ::pcrg/requires   {:a {}}
+                                ::pcrg/provides   {:a {}}}
+                             2 {::pcrg/node-id    2
+                                ::pcrg/after-node 3
+                                ::pc/sym          'a2
+                                ::pcrg/requires   {:a {}}
+                                ::pcrg/provides   {:a {}}}
+                             3 {::pcrg/node-id  3
+                                ::pcrg/provides {:a {}}
+                                ::pcrg/run-or   [1 2]
+                                ::pcrg/requires {:a {}}}}}))
+
+    (testing "with run-next"
+      (is (= (pcrg/compute-root-or
+               {::pcrg/provides {:a {}}
+                ::pcrg/requires {:a {}}
+                ::pcrg/root     2
+                ::pcrg/nodes    {2 {::pcrg/node-id  2
+                                    ::pc/sym        'a
+                                    ::pcrg/requires {:a {}}
+                                    ::pcrg/provides {:a {}}
+                                    ::pcrg/run-next 1}
+                                 3 {::pcrg/node-id  3
+                                    ::pc/sym        'a2
+                                    ::pcrg/requires {:a {}}
+                                    ::pcrg/provides {:a {}}
+                                    ::pcrg/run-next 1}}}
+               (assoc (base-graph-env) ::pcrg/id-counter (atom 3)
+                 ::pc/attribute :a
+                 ::pc/index-resolvers {'a  {::pc/provides {:a {}}}
+                                       'a2 {::pc/provides {:a {}}}})
+               {::pcrg/node-id 3})
+             {::pcrg/provides {:a {}}
+              ::pcrg/requires {:a {}}
+              ::pcrg/root     4
+              ::pcrg/nodes    {1 {::pcrg/after-node 4}
+                               2 {::pcrg/node-id    2
+                                  ::pc/sym          'a
+                                  ::pcrg/after-node 4
+                                  ::pcrg/requires   {:a {}}
+                                  ::pcrg/provides   {:a {}}}
+                               3 {::pcrg/node-id    3
+                                  ::pcrg/after-node 4
+                                  ::pc/sym          'a2
+                                  ::pcrg/requires   {:a {}}
+                                  ::pcrg/provides   {:a {}}}
+                               4 {::pcrg/node-id  4
+                                  ::pcrg/run-or   [2 3]
+                                  ::pcrg/requires {:a {}}
+                                  ::pcrg/provides {:a {}}
+                                  ::pcrg/run-next 1}}}))
+
+      (testing "don't optimize when run next is different"
+        (is (= (pcrg/compute-root-or
+                 {::pcrg/provides {:a {}}
+                  ::pcrg/requires {:a {}}
+                  ::pcrg/root     2
+                  ::pcrg/nodes    {2 {::pcrg/node-id  2
+                                      ::pc/sym        'a
+                                      ::pcrg/requires {:a {}}
+                                      ::pcrg/provides {:a {}}
+                                      ::pcrg/run-next 1}
+                                   3 {::pcrg/node-id  3
+                                      ::pc/sym        'a2
+                                      ::pcrg/requires {:a {}}
+                                      ::pcrg/provides {:a {}}
+                                      ::pcrg/run-next 10}}}
+                 (assoc (base-graph-env) ::pcrg/id-counter (atom 3)
+                   ::pc/attribute :a)
+                 {::pcrg/node-id 3})
+               {::pcrg/provides {:a {}}
+                ::pcrg/requires {:a {}}
+                ::pcrg/root     4
+                ::pcrg/nodes    {2 {::pcrg/node-id    2
+                                    ::pcrg/after-node 4
+                                    ::pc/sym          'a
+                                    ::pcrg/requires   {:a {}}
+                                    ::pcrg/provides   {:a {}}
+                                    ::pcrg/run-next   1}
+                                 3 {::pcrg/node-id    3
+                                    ::pcrg/after-node 4
+                                    ::pc/sym          'a2
+                                    ::pcrg/requires   {:a {}}
+                                    ::pcrg/provides   {:a {}}
+                                    ::pcrg/run-next   10}
+                                 4 {::pcrg/node-id  4
+                                    ::pcrg/run-or   [2 3]
+                                    ::pcrg/provides {:a {}}
+                                    ::pcrg/requires {:a {}}}}})))))
+
+  (testing "add to the runner"
+    (is (= (pcrg/compute-root-or
+             {::pcrg/provides {:a {}}
+              ::pcrg/requires {:a {}}
+              ::pcrg/root     3
+              ::pcrg/nodes    {1 {::pcrg/node-id  1
+                                  ::pc/sym        'a
+                                  ::pcrg/requires {:a {}}
+                                  ::pcrg/provides {:a {}}}
+                               2 {::pcrg/node-id  2
+                                  ::pc/sym        'a2
+                                  ::pcrg/requires {:a {}}
+                                  ::pcrg/provides {:a {}}}
+                               3 {::pcrg/node-id  3
+                                  ::pcrg/run-or   [1 2]
+                                  ::pcrg/requires {:a {}}}
+                               4 {::pcrg/node-id  4
+                                  ::pc/sym        'a3
+                                  ::pcrg/requires {:a {}}
+                                  ::pcrg/provides {:a {}}}}}
+             (base-graph-env)
+             {::pcrg/node-id 4})
+           {::pcrg/provides {:a {}}
+            ::pcrg/requires {:a {}}
+            ::pcrg/root     3
+            ::pcrg/nodes    {1 {::pcrg/node-id  1
+                                ::pc/sym        'a
+                                ::pcrg/requires {:a {}}
+                                ::pcrg/provides {:a {}}}
+                             2 {::pcrg/node-id  2
+                                ::pc/sym        'a2
+                                ::pcrg/requires {:a {}}
+                                ::pcrg/provides {:a {}}}
+                             3 {::pcrg/node-id  3
+                                ::pcrg/provides {:a {}}
+                                ::pcrg/run-or   [1 2 4]
+                                ::pcrg/requires {:a {}}}
+                             4 {::pcrg/node-id    4
+                                ::pcrg/after-node 3
+                                ::pc/sym          'a3
+                                ::pcrg/requires   {:a {}}
+                                ::pcrg/provides   {:a {}}}}}))
+
+    (testing "with run context"
+      (is (= (pcrg/compute-root-or
+               {::pcrg/provides {:a {}}
+                ::pcrg/requires {:a {}}
+                ::pcrg/root     3
+                ::pcrg/nodes    {1 {::pcrg/node-id  1
+                                    ::pc/sym        'a
+                                    ::pcrg/requires {:a {}}
+                                    ::pcrg/provides {:a {}}}
+                                 2 {::pcrg/node-id  2
+                                    ::pc/sym        'a2
+                                    ::pcrg/requires {:a {}}
+                                    ::pcrg/provides {:a {}}}
+                                 3 {::pcrg/node-id  3
+                                    ::pcrg/run-or   [1 2]
+                                    ::pcrg/requires {:a {}}
+                                    ::pcrg/run-next 10}
+                                 4 {::pcrg/node-id  4
+                                    ::pc/sym        'a3
+                                    ::pcrg/requires {:a {}}
+                                    ::pcrg/provides {:a {}}
+                                    ::pcrg/run-next 10}}}
+               (assoc (base-graph-env)
+                 ::pc/index-resolvers {'a3 {::pc/provides {:a {}}}})
+               {::pcrg/node-id 4})
+             {::pcrg/provides {:a {}}
+              ::pcrg/requires {:a {}}
+              ::pcrg/root     3
+              ::pcrg/nodes    {1 {::pcrg/node-id  1
+                                  ::pc/sym        'a
+                                  ::pcrg/requires {:a {}}
+                                  ::pcrg/provides {:a {}}}
+                               2 {::pcrg/node-id  2
+                                  ::pc/sym        'a2
+                                  ::pcrg/requires {:a {}}
+                                  ::pcrg/provides {:a {}}}
+                               3 {::pcrg/node-id  3
+                                  ::pcrg/provides {:a {}}
+                                  ::pcrg/run-or   [1 2 4]
+                                  ::pcrg/requires {:a {}}
+                                  ::pcrg/run-next 10}
+                               4 {::pcrg/node-id    4
+                                  ::pcrg/after-node 3
+                                  ::pc/sym          'a3
+                                  ::pcrg/requires   {:a {}}
+                                  ::pcrg/provides   {:a {}}}}})))))
+
+(deftest test-prepare-ast
+  (testing "returns parent query ast"
+    (is (= (pcrg/prepare-ast {::p/entity {}}
+             (p/query->ast [:foo]))
+           {:type     :root
+            :children [{:type :prop :dispatch-key :foo :key :foo}]})))
+
+  (testing "lift placeholders"
+    (is (= (pcrg/prepare-ast {::p/entity {}}
+             (p/query->ast [:foo
+                            {:>/placeholder [:bar]}]))
+           {:type     :root
+            :children [{:type :prop :dispatch-key :foo :key :foo}
+                       {:type :prop :dispatch-key :bar :key :bar}]})))
+
+  (testing "remove keys already present in entity"
+    (is (= (pcrg/prepare-ast {::p/entity {:foo 123}}
+             (p/query->ast [:foo
+                            {:>/placeholder [:bar]}]))
+           {:type     :root
+            :children [{:type :prop :dispatch-key :bar :key :bar}]}))))
+
 (defn internalize-remote-index [{::pc/keys [index-source-id] :as indexes}]
   (-> indexes
       (update ::pc/index-resolvers
@@ -1829,25 +1851,3 @@
          ::render-graphviz?    true
          ::time?               true}
         (pc/merge-indexes internal-index-by-service))))
-
-(deftest test-prepare-ast
-  (testing "returns parent query ast"
-    (is (= (pcrg/prepare-ast {::p/entity {}}
-             (p/query->ast [:foo]))
-           {:type     :root
-            :children [{:type :prop :dispatch-key :foo :key :foo}]})))
-
-  (testing "lift placeholders"
-    (is (= (pcrg/prepare-ast {::p/entity {}}
-             (p/query->ast [:foo
-                            {:>/placeholder [:bar]}]))
-           {:type     :root
-            :children [{:type :prop :dispatch-key :foo :key :foo}
-                       {:type :prop :dispatch-key :bar :key :bar}]})))
-
-  (testing "remove keys already present in entity"
-    (is (= (pcrg/prepare-ast {::p/entity {:foo 123}}
-             (p/query->ast [:foo
-                            {:>/placeholder [:bar]}]))
-           {:type     :root
-            :children [{:type :prop :dispatch-key :bar :key :bar}]}))))


[#1078] Make sure datasets are still able to be updated

--- backend/src/akvo/lumen/import.clj
+++ backend/src/akvo/lumen/import.clj
@@ -36,14 +36,14 @@
                                   :table-name table-name
                                   :imported-table-name imported-table-name
                                   :version 1
-                                  :columns (mapv (fn [{:keys [title id type key]}]
-                                                   {:type (name type)
-                                                    :title title
-                                                    :columnName (name id)
-                                                    :sort nil
-                                                    :key (boolean key)
-                                                    :direction nil
-                                                    :hidden false})
+                                  :columns (mapv (fn [{:keys [title id type key] :as columns}]
+                                                   (cond-> {:type (name type)
+                                                            :title title
+                                                            :columnName (name id)
+                                                            :sort nil
+                                                            :direction nil
+                                                            :hidden false}
+                                                     (contains? columns :key) (assoc :key (boolean key))))
                                                  columns)
                                   :transformations []})
     (update-successful-job-execution conn {:id job-execution-id})))
@@ -155,10 +155,12 @@
       columns)))

 (defn compatible-columns? [imported-columns columns]
+
   (let [imported-columns (map (fn [column]
-                                {:id (keyword (get column "columnName"))
-                                 :type (keyword (get column "type"))
-                                 :title (get column "title")})
+                                (cond-> {:id (keyword (get column "columnName"))
+                                         :type (keyword (get column "type"))
+                                         :title (get column "title")}
+                                  (contains? column "key") (assoc :key (boolean (get column "key")))))
                               imported-columns)]
     (set/subset? (set imported-columns)
                  (set columns))))
@@ -187,13 +189,14 @@
                                   {:transaction? false})
                 (let [new-columns (apply-transformation-log conn
                                                             table-name
-                                                            (mapv (fn [{:keys [title id type]}]
-                                                                    {"type" (name type)
-                                                                     "title" title
-                                                                     "columnName" (name id)
-                                                                     "sort" nil
-                                                                     "direction" nil
-                                                                     "hidden" false})
+                                                            (mapv (fn [{:keys [title id type key] :as column}]
+                                                                    (cond-> {"type" (name type)
+                                                                             "title" title
+                                                                             "columnName" (name id)
+                                                                             "sort" nil
+                                                                             "direction" nil
+                                                                             "hidden" false}
+                                                                      (contains? column :key) (assoc "key" (boolean key))) )
                                                                   columns)
                                                             transformations)]
                   (successful-update conn


Съем данных с dataform-search

Съем данных с dataform-search

--- radiolamp-6P3S/src/r6p3s/complex/dataform_search.cljs
+++ radiolamp-6P3S/src/r6p3s/complex/dataform_search.cljs
@@ -21,7 +21,7 @@

 (def ^:const padding 4)

-(declare selector-app-init selector-fill-rbs selector)
+(declare selector-app-init selector-fill-rbs selector selector-selected)

 (defn make-app-init
@@ -30,9 +30,10 @@
   {:on        toggle-button/app-init
    :rbtype    (->> rbs-scheme
                    :realtype
-                   vals
-                   (sort-by :ord)
-                   (map-indexed vector)
+                   seq
+                   (sort-by (comp :ord second))
+                   (map-indexed (fn [i [k r]]
+                                  [i (assoc r :realtype k)]))
                    (nav-tabs/app-state-i-maker)
                    (assoc nav-tabs/app-state :tabs))
    :selectors (->> rbs-scheme
@@ -41,6 +42,19 @@
                     (fn [a [k v]]
                       (assoc a k (selector-app-init k v)))
                     {}))})
+
+
+
+(defn selected [{:keys [on rbtype selectors] :as app} rbs-scheme]
+  (let [realtype (-> rbtype nav-tabs/active-tab-row :realtype)
+        fields   (get-in rbs-scheme [:realtype realtype :fields] #{})]
+    {:on?       (toggle-button/value on)
+     :realtype  realtype
+     :selectors (->> selectors seq
+                     (filter (comp fields first))
+                     (map (fn [[field row]]
+                            {:field    field
+                             :selected (selector-selected row)})))}))

@@ -163,9 +177,10 @@

-(defmulti selector-app-init (fn [_ {{stype :type} :search}] stype))
-(defmulti selector-fill-rbs (fn [_ {{stype :type} :search} _] stype))
-(defmulti selector          (fn [_ {{stype :type} :search} _] stype))
+(defmulti selector-app-init (fn [_ {{type :type} :search}] type))
+(defmulti selector-fill-rbs (fn [_ {{type :type} :search} _] type))
+(defmulti selector          (fn [_ {{type :type} :search} _] type))
+(defmulti selector-selected (fn [{:keys [type]}] type))

@@ -179,6 +194,10 @@
 (defmethod selector :default
   [_ {:keys [text] :as v} _]
   (cell text (dom/div #js {:className "text-danger"} "компонент не определен")))
+
+(defmethod selector-selected :default
+  [_]
+  nil)

@@ -209,7 +228,7 @@

 (defmethod selector-app-init :band-integer-from
-  [k {{:keys [buttons]} :search}]
+  [k _]
   input/app-init)

 (defmethod selector :band-integer-from
@@ -265,7 +284,7 @@

 (defmethod selector-app-init :boolean
-  [k {{:keys [buttons]} :search}]
+  [k _]
   toggle-button/app-init)

 (defmethod selector :boolean
@@ -281,15 +300,15 @@

 (defmethod selector-app-init :boolean-nm
-  [k {{:keys [buttons]} :search}]
+  [k _]
   (toggle-buttons-selector/app-init
-   [{:key  :nm
-     :text "неважно"
-     :value true}
-    {:key  :y
-     :text "да"}
-    {:key  :n
-     :text "нет"}]))
+            [{:key   :nm
+              :text  "неважно"
+              :value true}
+             {:key  :y
+              :text "да"}
+             {:key  :n
+              :text "нет"}]))

 (defmethod selector :boolean-nm
   [app {:keys [text]} chan-update]
@@ -309,7 +328,7 @@
   multi-select/app-init)

 (defmethod selector-fill-rbs :rbs-multi-select
-  [app m data]
+  [app _ data]
   (assoc app :data (vec data)))

 (defmethod selector :rbs-multi-select


Add aws url to caddisfly images [#1571]

Add aws url to caddisfly images [#1571]

--- backend/src/akvo/lumen/transformation/multiple_column/caddisfly.clj
+++ backend/src/akvo/lumen/transformation/multiple_column/caddisfly.clj
@@ -52,7 +52,7 @@
   [cell-value columns-to-extract]
   (map (fn [c]
          (if (:image (meta c))
-           (:image cell-value)
+           (format "https://akvoflow-uat1.s3.amazonaws.com/images/%s" (:image cell-value))
            (:value (some #(when (= (:caddisfly-test-id c) (:id %)) %) (:result cell-value)))))
    columns-to-extract))


Расширение селектора для input_select_checkboxes

--- radiolamp-6P3S/src/r6p3s/cpt/input_select_checkboxes.cljs
+++ radiolamp-6P3S/src/r6p3s/cpt/input_select_checkboxes.cljs
@@ -22,8 +22,11 @@
                         vec)))

-(defn get-selected [key-value app]
-  (->> app :data (filter key-value)))
+(defn get-selected
+  ([app]
+   (get-selected :value app))
+  ([key-value app]
+   (->> app :data (filter key-value))))


Rename symbols

Rename symbols

--- src/cljs/cglossa/search_inputs/cwb/impl/extended.cljs
+++ src/cljs/cglossa/search_inputs/cwb/impl/extended.cljs
@@ -15,14 +15,14 @@
        (str/join \|)
        re-pattern))

-(def interval #"\[\]\{(.+?)\}")
+(def interval-rx #"\[\]\{(.+?)\}")
 ;; Treat quoted strings separately; they may contain right brackets
-(def attribute-value #"\[\(?([^\"]+?(?:\"[^\"]*\"[^\]\"]*?)*?)(?:\s+%c)?\)?\]")
-(def quoted-or-empty-term #"\".*?\"|\[\]")
-(def terms-regex (combine-regexes [interval quoted-or-empty-term attribute-value]))
+(def attribute-value-rx #"\[\(?([^\"]+?(?:\"[^\"]*\"[^\]\"]*?)*?)(?:\s+%c)?\)?\]")
+(def quoted-or-empty-term-rx #"\".*?\"|\[\]")
+(def terms-rx (combine-regexes [interval-rx quoted-or-empty-term-rx attribute-value-rx]))

 (defn split-query [query]
-  (let [terms (re-seq terms-regex query)]
+  (let [terms (re-seq terms-rx query)]
     (if (str/blank? terms)
       ["[]"]
       terms)))
@@ -50,25 +50,25 @@
   ;; Use an atom to keep track of interval specifications so that we can set
   ;; them as the value of the :interval key in the map representing the following
   ;; query term.
-  (let [minmax (atom [nil nil])]
+  (let [interval (atom [nil nil])]
     (reduce (fn [terms part]
               (condp re-matches (first part)
-                interval (let [values (second part)
+                interval-rx (let [values (second part)
                                min    (some->> values
                                                (re-find #"(\d+),")
                                                last)
                                max    (some->> values
                                                (re-find #",(\d+)")
                                                last)]
-                           (reset! minmax [min max])
+                           (reset! interval [min max])
                            terms)
-                attribute-value (let [attrs (str/split (last part) #"\s*&\s*")
+                attribute-value-rx (let [attrs (str/split (last part) #"\s*&\s*")
                                       term  (as-> {} $
                                                   (reduce process-attr $ attrs)
-                                                  (assoc $ :interval @minmax))]
-                                  (reset! minmax [nil nil])
+                                                  (assoc $ :interval @interval))]
+                                  (reset! interval [nil nil])
                                   (conj terms term))
-                quoted-or-empty-term (.log js/console "quoted-or-empty")
+                quoted-or-empty-term-rx (.log js/console "quoted-or-empty")
                 "hei"))
             []
             parts)))


small fix

small fix

--- src/cljs/salava/extra/application/ui/application.cljs
+++ src/cljs/salava/extra/application/ui/application.cljs
@@ -352,7 +352,7 @@
       (into [:div.panel {:class "row wrap-grid"
                          :id    "grid"
                          :style {:padding "10px"}}
-             [:h3 [:i.fa.fa-star ] (str (if (> badge-count 1) (t :extra-application/Featuredbadges) (t :extra-application/Featuredbadge) ) #_" (" badge-count ")")]
+             [:h3 [:i.fa.fa-star ] (str " " (if (> badge-count 1) (t :extra-application/Featuredbadges) (t :extra-application/Featuredbadge) ))]
              [:hr]]
             (for [element-data badges]
               (badge-grid-element element-data state))))))


Add sensible ordering to select queries

Add sensible ordering to select queries

--- src/clojure/clojurewerkz/cassaforte/new_query_api.clj
+++ src/clojure/clojurewerkz/cassaforte/new_query_api.clj
@@ -94,40 +94,101 @@
      query-builder
      construct)))

+(def ^:private select-order
+  {:what      1
+   :from      2
+   :where     3
+   :order     4
+   :limit     4
+   :filtering 5})
+
+
+;;
+;; Columns
+;;
+
+(defn ttl
+  [column]
+  (fn ttl-query [query-builder]
+    (.ttl query-builder column)))
+
+(defn distinct*
+  [column]
+  (fn distinct-query [query-builder]
+    (.distinct (.column query-builder column))))
+
+(defn all
+  []
+  (fn all-query [query-builder]
+    (.all query-builder))
+  )
+(defn as
+  [wrapper alias]
+  (fn distinct-query [query-builder]
+    (.as (wrapper query-builder) alias)))
+
+(defn columns
+  [columns]
+  [:what (fn [^Select$Selection query-builder]
+           (reduce (fn [^Select$Selection builder column]
+                     (if (string? column)
+                       (.column builder column)
+                       (column builder)))
+                   query-builder
+                   columns))])
+
+
+(defn column
+  [column & {:keys [as]}]
+  [:what (fn column-query [^Select$Selection query-builder]
+           (let [c (.column query-builder column)]
+             (if as
+               (.as c as)
+               c)))])
+
 (defn where
   [m]
-  [3 (fn where-query [^Select query-builder]
-       (build-where m (.where query-builder)))])
-
-(defn asc
-  [^String column-name]
-  (QueryBuilder/asc (name column-name)))
-
-(defn desc
-  [^String column-name]
-  (QueryBuilder/desc column-name))
+  [:where
+   (fn where-query [^Select query-builder]
+     (build-where m (.where query-builder)))])

 (defn order-by
   [orderings]
-  [2 (fn order-by-query [^Select query-builder]
-       (.orderBy query-builder (into-array orderings)))])
+  [:order
+   (fn order-by-query [^Select$Where query-builder]
+     (.orderBy query-builder (into-array orderings)))])

 (defn limit
   [lim]
-  [2 (fn order-by-query [^Select  query-builder]
-       (.limit query-builder (int lim)))])
+  [:limit
+   (fn order-by-query [^Select  query-builder]
+     (.limit query-builder (int lim)))])

 (defn allow-filtering
   []
-  [2 (fn order-by-query [^Select  query-builder]
-       (.allowFiltering query-builder))])
-   ;;  public Select limit(BindMarker marker) {
-   ;;  public Select allowFiltering() {
+  [:filtering
+   (fn order-by-query [^Select  query-builder]
+     (.allowFiltering query-builder))])
+
+(defn- from
+  [^String table-name]
+  [:from (fn from-query [^Select$Selection query-builder]
+           (.from query-builder (name table-name))
+           )])
+
+(defn- complete-select-query
+  [statements]
+  (let [query-map (into {} statements)]
+    (if (nil? (:what query-map))
+      (conj query-map
+            [:what (all)])
+      statements)))

 (defn select
   [table-name & statements]
   (->> (conj statements (from (name table-name)))
-       (sort-by first)
+       (complete-select-query)
+       (sort-by #(get select-order (first %)))
        ;; (map println)
        (map second)
        (reduce (fn [builder statement]
@@ -137,8 +198,6 @@
                )
        (.toString)
        ))
-
-

 ;; Select.Builder select(String... columns)
 ;; Select.Selection select()


more on concurrency from the joy of clojure

--- src/clojure_learning/chap-10-mutation-and-concurrency.clj
+++ src/clojure_learning/chap-10-mutation-and-concurrency.clj
@@ -394,41 +394,40 @@
 ;; mutate the value of a var. I'm not interested in mutation when it comes to Clojure but we have to know
 ;; that we CAN if we want :)

+;;;;;;;;;;;;
+;; A little more about Clojure Concurrency Model from: the joy of clojure
+;;;;;;;;;;;;
+;; Because each transaction has its own isolated snapshot, a retry is harmless.
+;; Clojure allows for only 1 transaction per thread.
+;; The STM allows you to perform arbitrary sets of read/write operations on arbitrary
+;; sets of data in a consistent (Papadimitriou 1986) way.
+;; With Clojure we get a consistent view of the world without any manually locking mechanisms.
+;; In applications of any size, the inclusiion of locks for managing concurrent access to shared mutable state,
+;; ads an un-necessary complexity(incidental complexity);
+;; with manual locking, one should handle very granularly each lock once an exception is being thrown.
+;; since the exception might be thrown from one thread and the lock can be held from a thread that died.
+;; With Clojure we wont have any deadlocks at all.
+
+;; The things that make Clojure STM unhappy:
+;; 1. Any I/O operation in the body of a transaction is highly discouraged.
+;; this is because transactions are "restarted" and a I/O operation which has side effects makes
+;; the I/O operation repeatable for every transaction restart. To workaround this always use: [io!] macro
+;; when in transaction and require accidentally I/O operations.
+(io! (println "printing something nice"))
+
+;; when in transactions, and have I/O operations: the above invocation would throw an exception:
+(dosync (io! (println "in transaction -> throwing exception")))
+;; java.lang.IllegalStateException: I/O in transaction
+
+;; I/O in transactions are somehow evil, so take special care with I/O
+
+;; 2. rule is to not perform mutations on mutable objects within transactions!
+
+;; 3. Avoid large transactions(that are large units of work in a transaction). This is somehow hard to track,
+;; but a general rule of thumb is: "get in and get out as quickly as possible" :)
+
+
 ;;;;;;;;;;;;;;;
 ;; Clojure parallelism with: pmap (divide and conquer)
 ;;;;;;;;;;;;;;;

-
-(ns for-clojure)
-(declare struct-type?)
-(map struct-type? [#{} {} [] '()])  ;; (:set :map :vector :list)
-(defn struct-type?
-  [ds]
-  (let [seqable? (fn [xs ys]
-                   (and (= (inc (count xs)) (count ys)) (nil? (get ys xs))))
-        new-ds (conj ds ds)]
-    (if (seqable? ds new-ds)
-      (if (identical? (last new-ds) ds)
-        :vector
-        (if (identical? (first new-ds) ds)
-          :list))
-      (if (= new-ds ds)
-        :map
-        :set
-       ))))
-
-(struct-type? [1 2])
-(struct-type? [])
-(struct-type? {})
-(struct-type? #{})
-(conj [] [])
-(conj [1 2] [1 2])
-(conj [:a :b] [:a :b])
-(def ab (conj [:a :b] [:a :b]))
-(get ab [:a :b])
-
-(def ab (conj {:a :b} {:a :b}))
-(get ab {:a :b})
-(count [[]])
-(def lol (conj '() '()))
-(first lol)


Simplify (devview) and (block) to make use of (inline).

--- src/main/clojure/com/howardlewisship/cascade.clj
+++ src/main/clojure/com/howardlewisship/cascade.clj
@@ -15,6 +15,11 @@
 (ns com.howardlewisship.cascade
   (:use (com.howardlewisship.cascade.internal utils viewbuilder)))

+(defmacro inline
+  "Defines a block of template that renders inline."
+  [& template]
+  (parse-embedded-template template))
+
 (defmacro defview
   "Defines a Cascade view function, which uses an embedded template."
   [fn-name fn-params & template]
@@ -22,8 +27,7 @@
   (fail-unless (vector? fn-params) "Must provide parameters (as with any function).")
   (fail-unless (not (empty? fn-params)) "At least one parameter (for the environment) is required when defining a view function.")
   ; TODO: add meta data
-  (let [parsed (parse-embedded-template template)]
-    `(defn ~fn-name ~fn-params ~parsed)))
+  `(defn ~fn-name ~fn-params (inline ~@template)))

 (defmacro inline
   "Defines a block of template that renders inline."
@@ -35,8 +39,7 @@
 that takes a single parameter (the env map)."
   [fn-params & template]
   (fail-unless (and (vector? fn-params) (= 1 (count fn-params))) "Blocks require that exactly one parameter be defined.")
-  (let [parsed (parse-embedded-template template)]
-    `(fn ~fn-params ~parsed)))
+    `(fn ~fn-params (inline ~@template)))

 (def linebreak
   (text-node "\r"))


add beam icon to iconpiler

add beam icon to iconpiler


fixed list-documents sorting by :ts

fixed list-documents sorting by :ts

--- src/app/cljs/one/sample/view/editor.cljs
+++ src/app/cljs/one/sample/view/editor.cljs
@@ -72,9 +72,9 @@

 (defn list-documents [documents]
   (let [element ($ "#sidebar-documents > ol")
-        sorted  (reverse (sort-by :ts documents))]
+        sorted  (reverse (sort-by :ts (vals documents)))]
     (destroy-children! element)
-    (doseq [[id doc] sorted]
+    (doseq [{id :id :as doc} sorted]
       (append! element (single-node (str "
"
                                            "
"
                                              ""


étudier -> étudions, not étudiions

étudier -> étudions, not étudiions

--- src/babel/francais/morphology/verbs.cljc
+++ src/babel/francais/morphology/verbs.cljc
@@ -606,10 +606,22 @@
      :u {:synsem {:agr {:number :sing
                         :person :3rd}}}}

+    ;; étudier -> étudions
+    {:p [#"^(\S+)ions$"      "$1ier"]
+     :g [#"^([^' ]+)ier$"    "$1ions"]
+     :u {:synsem {:agr {:number :plur
+                        :person :1st}}}}
+
     {:p [#"^(\S+)ions$"      "$1er"]
      :g [#"^([^' ]+)er$"     "$1ions"]
      :u {:synsem {:agr {:number :plur
                         :person :1st}}}}
+
+    ;; étudier -> étudiez
+    {:p [#"^(\S+)iez$"       "$1er"]
+     :g [#"^([^' ]+)ier$"    "$1iez"]
+     :u {:synsem {:agr {:number :plur
+                        :person :2nd}}}}

     {:p [#"^(\S+)iez$"       "$1er"]
      :g [#"^([^' ]+)er$"     "$1iez"]


rename socket cache vars to be less confusing with the assignment vars

--- src/clj/backtype/storm/daemon/worker.clj
+++ src/clj/backtype/storm/daemon/worker.clj
@@ -158,8 +158,8 @@
       :component->stream->fields (component->stream->fields (:system-topology <>))
       :component->sorted-tasks (->> (:task->component <>) reverse-map (map-val sort))
       :endpoint-socket-lock (mk-rw-lock)
-      :node+port->socket (atom {})
-      :task->node+port (atom {})
+      :cached-node+port->socket (atom {})
+      :cached-task->node+port (atom {})
       :transfer-queue transfer-queue
       :executor-receive-queue-map executor-receive-queue-map
       :short-executor-receive-queue-map (map-key first executor-receive-queue-map)
@@ -189,10 +189,10 @@
                                       (filter-key (complement (-> worker :task-ids set)))
                                       vals
                                       set)
-              current-connections (set (keys @(:node+port->socket worker)))
+              current-connections (set (keys @(:cached-node+port->socket worker)))
               new-connections (set/difference needed-connections current-connections)
               remove-connections (set/difference current-connections needed-connections)]
-              (swap! (:node+port->socket worker)
+              (swap! (:cached-node+port->socket worker)
                      merge
                      (into {}
                        (dofor [[node port :as endpoint] new-connections]
@@ -205,11 +205,11 @@
                           ]
                          )))
               (write-locked (:endpoint-socket-lock worker)
-                (reset! (:task->node+port worker) my-assignment))
+                (reset! (:cached-task->node+port worker) my-assignment))
               (doseq [endpoint remove-connections]
-                (.close (@(:node+port->socket worker) endpoint)))
+                (.close (@(:cached-node+port->socket worker) endpoint)))
               (apply swap!
-                     (:node+port->socket worker)
+                     (:cached-node+port->socket worker)
                      dissoc
                      remove-connections)
           )))))
@@ -229,8 +229,8 @@
 (defn mk-transfer-tuples-handler [worker]
   (let [^DisruptorQueue transfer-queue (:transfer-queue worker)
         drainer (ArrayList.)
-        node+port->socket (:node+port->socket worker)
-        task->node+port (:task->node+port worker)
+        node+port->socket (:cached-node+port->socket worker)
+        task->node+port (:cached-task->node+port worker)
         endpoint-socket-lock (:endpoint-socket-lock worker)
         ]
     (fn [packets _ batch-end?]
@@ -299,7 +299,7 @@
                     (doseq [[_ q] (:executor-receive-queue-map worker)]
                       (.haltProcessing q))
                     (doseq [executor executors] (.shutdown executor))
-                    (doseq [[_ socket] @(:node+port->socket worker)]
+                    (doseq [[_ socket] @(:cached-node+port->socket worker)]
                       ;; this will do best effort flushing since the linger period
                       ;; was set on creation
                       (.close socket))


whitespace

whitespace

--- src/clj/infinitelives/pixi/pixelfont.clj
+++ src/clj/infinitelives/pixi/pixelfont.clj
@@ -83,7 +83,7 @@
 (def ascii-chars "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~")

 (defmacro pixel-font[font-name filename [x1 y1] [x2 y2] &
-                     {:keys [chars processors kerning]
+                     {:keys [chars processors kerning space]
                       :or {chars default-chars
                            processors []
                            kerning {}
@@ -112,10 +112,7 @@
                                          (offset-dimensions :x2 dec)
                                          (process-row 0 :x1 + 10)
                                          ]
-                            :chars "AB"))
-)
-
-
+                            :chars "AB")))

 (comment
   (def a (-> "test.png"
@@ -124,15 +121,7 @@
                                         ;(horizontal-strips 0 200 0 200)
                                         ;(process-line 0 1000 89 96)

-
-
-
-
              (char-dimensions 127 350 84 128 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
              (offset-dimensions :x2 dec)
              (process-row 0 :x1 + 10)
-             (process-row 1 :x2 number?))
-
-    )
-
-  )
+             (process-row 1 :x2 number?))))


cleanup

cleanup

--- src/clojure/zensols/nlparse/stanford.clj
+++ src/clojure/zensols/nlparse/stanford.clj
@@ -399,11 +399,3 @@

 (dyn/register-purge-fn reset)
 (initialize)
-
-(do
-  (-> *parse-context* :tok-re-annotator (#(reset! % nil)))
-  (-> *parse-context* :pipeline-inst (#(reset! % nil)))
-  (->> (parse "I like Teddy Grams on Tuesday")
-       ;:tok-re-mentions
-       clojure.pprint/pprint
-       ))


Debug distinct-size-and-instruction-diversifying?

--- src/clojush/pushgp/genetic_operators.clj
+++ src/clojush/pushgp/genetic_operators.clj
@@ -988,8 +988,8 @@
                           (hash-set (keys (frequencies (map :instruction genome)))))
         kid-sets (map instruction-set kids)]
     (assoc ind :diversifying
-      (and (distinct? (conj kid-counts (count g)))
-           (distinct? (conj kid-sets (instruction-set g)))))))
+      (and (apply distinct? (conj kid-counts (count g)))
+           (apply distinct? (conj kid-sets (instruction-set g)))))))

 (defn three-gens-size-and-instruction-diversifying?
   [ind argmap]


bring back default npm build

bring back default npm build

--- src/main/shadow/cljs/devtools/config.clj
+++ src/main/shadow/cljs/devtools/config.clj
@@ -95,6 +95,11 @@

    :builds {}})

+(def default-builds
+  {:npm {:id :npm
+         :target :npm-module
+         :output-dir "node_modules/shadow-cljs"}})
+
 (defn load-cljs-edn []
   (let [file (io/file "shadow-cljs.edn")]
     (if-not (.exists file)
@@ -104,6 +109,7 @@
           (edn/read-string)
           (normalize)
           (->> (merge default-config))
+          (update :builds #(merge default-builds %))
           ))))

 (defn load-cljs-edn! []


(PDB-2478) services: serialize cleanup via locking

Hold a new lock while cleaning up, so that only one operation can be in
progress at a time.  Given the use of interspaced to schedule all
invocations, this should have no effect on the current behavior, but
will support the forthcoming cleanup trigger function.

--- src/puppetlabs/puppetdb/cli/services.clj
+++ src/puppetlabs/puppetdb/cli/services.clj
@@ -73,6 +73,7 @@
             [schema.core :as s]
             [slingshot.slingshot :refer [throw+ try+]])
   (:import [javax.jms ExceptionListener]
+           [java.util.concurrent.locks ReentrantLock]
            [org.joda.time Period]))

 (def cli-description "Main PuppetDB daemon")
@@ -161,12 +162,15 @@
   "Cleans up the resources specified by request, or everything if
   request is empty?."
   [db
+   lock :- ReentrantLock
    {:keys [node-ttl node-purge-ttl report-ttl]} :- {:node-ttl Period
                                                     :node-purge-ttl Period
                                                     :report-ttl Period
                                                     s/Keyword s/Any}
    ;; Later, the values might be maps, i.e. {:limit 1000}
    request :- clean-request-schema]
+  (when-not (.isHeldByCurrentThread lock)
+    (throw (IllegalStateException. "cleanup lock is not already held")))
   (let [request (if (empty? request) clean-options (set request))]
     (when (request "expire_nodes")
       (auto-expire-nodes! node-ttl db))
@@ -306,7 +310,8 @@
                      (throw e)))
           globals {:scf-read-db read-db
                    :scf-write-db write-db
-                   :pretty-print pretty-print}]
+                   :pretty-print pretty-print}
+          clean-lock (ReentrantLock.)]
       (transfer-old-messages! (conf/mq-endpoint config))

       (when-not disable-update-checking
@@ -330,10 +335,15 @@
                                   "purge_reports"))
                               "other"])]
             (interspaced gc-interval-millis
-                         #(try
-                            (clean-up write-db database what)
-                            (catch Exception ex
-                              (log/error ex)))
+                         (fn []
+                           (.lock clean-lock)
+                           (try
+                             (try
+                               (clean-up write-db clean-lock database what)
+                               (catch Exception ex
+                                 (log/error ex)))
+                             (finally
+                               (.unlock clean-lock))))
                          job-pool)))
         (when (pos? dlo-compression-interval-millis)
           (interspaced dlo-compression-interval-millis
@@ -342,7 +352,8 @@
         (assoc context
                :job-pool job-pool
                :broker broker
-               :shared-globals globals)))))
+               :shared-globals globals
+               :clen-up-lock clean-lock)))))

 (defprotocol PuppetDBServer
   (shared-globals [this])


Remove unit :lb/gal

Remove unit :lb/gal

--- src/test_utils/fracture_diagnostics.cljc
+++ src/test_utils/fracture_diagnostics.cljc
@@ -24,7 +24,7 @@
                             :length                 [:ft :m]
                             :mass                   [:lb :kg]
                             :power                  [:hp :W]
-                            :proppant-concentration [:lb-per-gal :lb/gal :kg-per-m3]
+                            :proppant-concentration [:lb-per-gal :kg-per-m3]
                             :slurry-rate            [:bpm :m3-per-min]
                             :volume                 [:bbl :m3]
                             :temperature            [:F :C]}]
@@ -450,8 +450,7 @@
    (let [unit (rand-proppant-concentration-unit)]
      (typical-proppant-concentration unit)))
   ([unit]
-   (let [typical-value (cond (or (= unit :lb-per-gal)
-                                 (= unit :lb/gal))
+   (let [typical-value (cond (= unit :lb-per-gal)
                              (value-from-typical-range 0.2 10)
                              (or (= unit :kg-per-m3)
                                  (= unit :kg/m3))
@@ -654,4 +653,11 @@
         measurement (generate-measurement-f unit)]
     [measurement (measurement-as-f measurement (first (remove (partial = unit) units)))]))

-(generate-pair #{:hp :W} rand-power-unit typical-power power-as)
+;(generate-pair #{:lb-per-gal :kg-per-m3}
+;               rand-proppant-concentration-unit
+;               typical-proppant-concentration
+;               proppant-concentration-as)
+(repeatedly 10 (fn [] (generate-pair #{:lb-per-gal :kg-per-m3}
+                                     rand-proppant-concentration-unit
+                                     typical-proppant-concentration
+                                     proppant-concentration-as)))


draw compound objects

draw compound objects

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

--- plugins/SlideExplorer2/src/slide_explorer/canvas.clj
+++ plugins/SlideExplorer2/src/slide_explorer/canvas.clj
@@ -166,7 +166,7 @@
          (filter second)
          (into {}))))

-(defmulti make-obj (fn [obj-keyword params] obj-keyword))
+(defmulti make-obj (fn [obj-keyword params] obj-keyword) :default :compound)

 (defmethod make-obj :arc
   [_ {:keys [l t w h start-angle arc-angle arc-boundary closed]}]
@@ -224,7 +224,7 @@
   (let [width (:width stroke)]
     (or (nil? width) (pos? width))))

-(defmulti draw-primitive (fn [g2d obj params] (type obj)))
+(defmulti draw-primitive (fn [g2d obj params & inner-items] (type obj)))

 (defmethod draw-primitive Shape
   [g2d shape {:keys [color fill stroke] :as params}]
@@ -287,22 +287,20 @@
                        (draw-string-center g2d text x y))
       )))

-(defn draw-primitives [g2d items]
+(defn draw [g2d items]
   (enable-anti-aliasing g2d)
-  (doseq [[type params inner] items]
-    (when type
+  (doseq [[type params & inner-items] items]
     (let [params+ (complete-coordinates params)]
-      (draw-primitive g2d (make-obj type params+) params+)))))
-
-
-(defn paint-canvas-graphics [^Graphics graphics data]
-  (draw-primitives graphics data))
+       (if (= type :compound)
+         (draw g2d inner-items)
+         (draw-primitive g2d (make-obj type params+) params+)
+         ))))

 (defn canvas [reference]
   (let [panel (proxy [JPanel] []
                 (paintComponent [^Graphics graphics]
-                                (proxy-super paintComponent graphics)
-                                (paint-canvas-graphics graphics @reference)))]
+                                ;(proxy-super paintComponent graphics)
+                                (draw graphics @reference)))]
     (add-watch reference panel (fn [_ _ _ _]
                                  (.repaint panel)))
     panel))
@@ -319,7 +317,7 @@
       .show)
     panel))

-(defn demo-atom []
+(defn demo-canvas []
   (canvas-frame grafix))

 (defn demo-animation [reference]
@@ -353,6 +351,16 @@
       .show)))

 (def img (read-image "/Users/arthur/Desktop/flea.png"))
+
+; shape
+; stroke color
+; fill color/pattern/image
+; rotate
+; scale
+; font
+; text
+; alpha
+

 (count
 (reset!
@@ -398,17 +406,19 @@
             :underline false
             :strikethrough false
             :size 50}}]
-   [:ellipse
-    {:x 350 :y 350 :w 40 :h 40 :fill {:color :pink}
-     :stroke {:width 4 :color 0xE06060}}]
-   [:line
-    {:x 350 :y 350 :w 18 :h 18 :color :white :alpha 0.8
-     :stroke {:width 7 :cap :butt}}]
+   [:compound
+    {:x 350 :y 350 :w 40 :h 40}
+    [:ellipse
+     {:x 350 :y 350 :w 40 :h 40 :fill {:color :pink}
+      :stroke {:width 4 :color 0xE06060}}]
+    [:line
+     {:x 350 :y 350 :w 18 :h 18 :color :white :alpha 0.8
+      :stroke {:width 7 :cap :butt}}]
+    [:line
+     {:x 350 :y 350 :w -18 :h 18 :fill false :color :white :alpha 0.8
+      :stroke {:width 7 :cap :butt}}]]
    [:image
-    {:x 200 :t 150 :data img :rotate 171}]
-   [:line
-    {:x 350 :y 350 :w -18 :h 18 :fill false :color :white :alpha 0.8
-     :stroke {:width 7 :cap :butt}}]
+     {:x 200 :t 150 :data img :rotate 171}]
    [:line
     {:x 180 :y 220 :w 0 :h 50 :color :red
      :stroke {:width 10 :cap :round}


slow down

slow down

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

--- plugins/SlideExplorer2/src/slide_explorer/canvas.clj
+++ plugins/SlideExplorer2/src/slide_explorer/canvas.clj
@@ -2,7 +2,6 @@
   (:import (java.awt Graphics Graphics2D RenderingHints)
            (java.awt Color Font Polygon)
            (javax.swing JFrame JPanel)))
-

 (defn enable-anti-aliasing
   "Turn on (off) anti-aliasing for a graphics context."
@@ -146,7 +145,7 @@

 (defn demo-animation [reference]
   (dotimes [i 200]
-  (Thread/sleep 10)
+  (Thread/sleep 30)
   (swap! reference (fn [data]
                      (-> data
                          (assoc-in [0 :params :w] (+ i 100))


(SERVER-876) Update master_core test to pass environment in body of request

--- test/unit/puppetlabs/services/master/master_core_test.clj
+++ test/unit/puppetlabs/services/master/master_core_test.clj
@@ -25,7 +25,10 @@
         request     (partial app-request app)]
     (is (= 200 (:status (request "/v3/environments"))))
     (is (= 200 (:status (request "/v3/catalog/bar?environment=environment1234"))))
-    (is (= 200 (:status (request :post "/v3/catalog/bar?environment=environment1234"))))
+    (is (= 200 (:status (app (-> {:request-method :post
+                                  :uri "/v3/catalog/bar"
+                                  :content-type "application/x-www-form-urlencoded"}
+                                 (mock/body "environment=environment1234"))))))
     (is (= 404 (:status (request "/foo"))))
     (is (= 404 (:status (request "/foo/bar"))))
     (doseq [[method paths]


Address #88 by bumping versions in template project.clj (#108)

--- templates/serverless/src/leiningen/new/serverless_cljs/project.clj
+++ templates/serverless/src/leiningen/new/serverless_cljs/project.clj
@@ -1,6 +1,6 @@
 (defproject {{name}} "0.1.0-SNAPSHOT"
-  :dependencies [[org.clojure/clojure       "1.8.0"]
-                 [org.clojure/clojurescript "1.8.51"]
+  :dependencies [[org.clojure/clojure       "1.9.0"]
+                 [org.clojure/clojurescript "1.10.312"]
                  [io.nervous/cljs-lambda    "0.3.5"]]
   :plugins [[lein-npm                    "0.6.2"]
             [io.nervous/lein-cljs-lambda "0.6.6"]]
@@ -11,4 +11,4 @@
                            :output-dir    "target/{{name}}"
                            :target        :nodejs
                            :language-in   :ecmascript5
-                           :optimizations :none}}})
+                           :optimizations :simple}}})


cleaning up spec (removing duplicate db/id in person-db)

--- src/test/untangled/components/ui/forms_spec.cljs
+++ src/test/untangled/components/ui/forms_spec.cljs
@@ -17,7 +17,7 @@
           "defaults as a to-one relation"
           (:input/cardinality f) => :one
           "is marked as a subform"
-          (true? (:input/is-form? f)) => true
+          f =fn=> f/is-subform?
           "has the correct type"
           (:input/type f) => ::f/subform
           "tracks the class of the subform UI"
@@ -31,7 +31,7 @@
           "defaults as a to-many relation"
           (:input/cardinality f) => :many
           "is marked as a subform"
-          (true? (:input/is-form? f)) => true
+          f =fn=> f/is-subform?
           "has a subform selection key"
           (:input/select-key f) => :k
           "has the correct type"
@@ -179,15 +179,15 @@

 (def person-db {:phone/by-id  {1 {:db/id 1 :phone/number "555-1212"}
                                2 {:db/id 2 :phone/number "555-3345"}}
-                :people/by-id {1 {:db/id 1 :person/name "A" :person/number [:phone/by-id 1]}
-                               3 {:db/id 3 :person/name "B"}
+                :people/by-id {3 {:db/id 3 :person/name "B"}
+                               7 {:db/id 7 :person/name "A" :person/number [:phone/by-id 1]}
                                5 {:db/id 5 :person/name "D" :person/number []}
                                4 {:db/id 4 :person/name "C" :person/number [[:phone/by-id 1] [:phone/by-id 2]]}
                                6 {:db/id 6 :person/name "E" :person/number [[:phone/by-id 1]]}}})

 (specification "Initializing a to-one form relation"
   (let [app-state person-db
-        base-form (get-in app-state [:people/by-id 1])
+        base-form (get-in app-state [:people/by-id 7])
         spec (-> (f/form-elements Person) first)]
     (when-mocking
       (f/init-form* state class ident v) =1x=> (do
@@ -241,7 +241,7 @@
       "Is ok when the target field is nil"
       (f/init-many person-db (get-in person-db [:people/by-id 3]) spec {}) => person-db
       "Throws an error when targeting a to-one"
-      (f/init-many person-db (get-in person-db [:people/by-id 1]) spec {}) =throws=> (js/Error.))))
+      (f/init-many person-db (get-in person-db [:people/by-id 7]) spec {}) =throws=> (js/Error.))))

 (specification "Initializing a form recursively"
   (assertions
@@ -253,33 +253,33 @@

     (assertions
       "Just returns the unmodified app state"
-      (f/init-form person-db Person [:people/by-id 1]) => person-db))
+      (f/init-form person-db Person [:people/by-id 7]) => person-db))
   (provided "when the form is partially initialized (to-one)"
     (f/initialized? f) => (boolean (:person/name f))

-    (let [result (f/init-form person-db Person [:people/by-id 1])]
+    (let [result (f/init-form person-db Person [:people/by-id 7])]
       (assertions
         "still initializes the nested form"
-        (get-in result [:phone/by-id 1 :ui/form :ident]) => [:phone/by-id 1])))
+        (f/form-ident (get-in result [:phone/by-id 1])) => [:phone/by-id 1])))
   (provided "when the form is partially initialized (to-many)"
     (f/initialized? f) => (= 4 (:db/id f))

     (let [result (f/init-form person-db PolyPerson [:people/by-id 4])]
       (assertions
         "still initializes the nested form"
-        (get-in result [:phone/by-id 1 :ui/form :ident]) => [:phone/by-id 1]
-        (get-in result [:phone/by-id 2 :ui/form :ident]) => [:phone/by-id 2])))
-  (let [actual (f/init-form person-db Person [:people/by-id 1])]
+        (f/form-ident (get-in result [:phone/by-id 1])) => [:phone/by-id 1]
+        (f/form-ident (get-in result [:phone/by-id 2])) => [:phone/by-id 2])))
+  (let [actual (f/init-form person-db Person [:people/by-id 7])]
     (assertions
       "properly initializes a nested to-one form (integration)"
-      (get-in actual [:people/by-id 1 :ui/form :ident]) => [:people/by-id 1]
-      (get-in actual [:phone/by-id 1 :ui/form :ident]) => [:phone/by-id 1]))
+      (f/form-ident (get-in actual [:people/by-id 7])) => [:people/by-id 7]
+      (f/form-ident (get-in actual [:phone/by-id 1])) => [:phone/by-id 1]))
   (let [actual (f/init-form person-db PolyPerson [:people/by-id 4])]
     (assertions
       "properly initializes a nested to-many form (integration)"
-      (get-in actual [:people/by-id 4 :ui/form :ident]) => [:people/by-id 4]
-      (get-in actual [:phone/by-id 1 :ui/form :ident]) => [:phone/by-id 1]
-      (get-in actual [:phone/by-id 2 :ui/form :ident]) => [:phone/by-id 2])))
+      (f/form-ident (get-in actual [:people/by-id 4])) => [:people/by-id 4]
+      (f/form-ident (get-in actual [:phone/by-id 1])) => [:phone/by-id 1]
+      (f/form-ident (get-in actual [:phone/by-id 2])) => [:phone/by-id 2])))

 (defui LeafForm
   static uc/InitialAppState
@@ -360,37 +360,44 @@
     "gives back pairs of [prop-path class] on a singly-nested form"
     (f/subforms* Level2Form) => [[[:leaf1] LeafForm] [[:leaf2] LeafForm] [[:leaf3] LeafForm]]
     "gives back pairs of [prop-path class] on a nested form"
-    (f/subforms* Level3Form) => [[[:level2] Level2Form] [[:level2 :leaf1] LeafForm] [[:level2 :leaf2] LeafForm] [[:level2 :leaf3] LeafForm]]
+    (f/subforms* Level3Form) => [[[:level2] Level2Form] [[:level2 :leaf1] LeafForm]
+                                 [[:level2 :leaf2] LeafForm] [[:level2 :leaf3] LeafForm]]
     "supports to-many sub-forms"
     (f/subforms* ToManyForm) => [[[:leaves] LeafForm]]))

-(def nested-form-db (om/tree->db [{:root (om/get-query Level3Form)}] {:root (uc/initial-state Level3Form {})} true))
-(def tomany-form-db (om/tree->db [{:root (om/get-query ToManyForm)}] {:root (uc/initial-state ToManyForm {})} true))
+(def nested-form-db (om/tree->db [{:root (om/get-query Level3Form)}]
+                      {:root (uc/initial-state Level3Form {})}, true))
+(def tomany-form-db (om/tree->db [{:root (om/get-query ToManyForm)}]
+                      {:root (uc/initial-state ToManyForm {})}, true))

 (specification "to-idents"
   (assertions
     "finds a sequence of idents by walking the graph (to-one)"
-    (f/to-idents person-db (get-in person-db [:people/by-id 1]) [:person/number]) => [[:phone/by-id 1]]
+    (f/to-idents person-db (get-in person-db [:people/by-id 7]) [:person/number]) => [[:phone/by-id 1]]
     "finds a sequence of idents by walking the graph (to-many)"
     (f/to-idents tomany-form-db (get-in tomany-form-db [:tomform 99]) [:leaves]) => [[:leaf 3] [:leaf 4]]))

 (specification "get-forms"
   (assertions
     "Obtains a list of nested forms and idents that are BOTH declared as subforms AND are present (others are skipped)."
-    (f/get-forms nested-form-db Level3Form [:level3 1]) => [{:ident [:level3 1] :class Level3Form :form {:id 1 :level3 true :other-root [:other 100] :level2 [:level2 2]}}
-                                                            {:ident [:level2 2] :class Level2Form :form {:id 2 :value 1 :level2 true :leaf1 [:leaf 5] :leaf2 [:leaf 6]}}
-                                                            {:ident [:leaf 5] :class LeafForm :form {:id 5 :value 1 :leaf true}}
-                                                            {:ident [:leaf 6] :class LeafForm :form {:id 6 :value 1 :leaf true}}]
+    (f/get-forms nested-form-db Level3Form [:level3 1])
+    => [{:ident [:level3 1] :class Level3Form
+         :form {:id 1 :level3 true :other-root [:other 100] :level2 [:level2 2]}}
+        {:ident [:level2 2] :class Level2Form
+         :form {:id 2 :value 1 :level2 true :leaf1 [:leaf 5] :leaf2 [:leaf 6]}}
+        {:ident [:leaf 5] :class LeafForm :form {:id 5 :value 1 :leaf true}}
+        {:ident [:leaf 6] :class LeafForm :form {:id 6 :value 1 :leaf true}}]
     "Can pull to-many relations of sub-forms"
-    (f/get-forms tomany-form-db ToManyForm [:tomform 99]) => [{:ident [:tomform 99]
-                                                               :class ToManyForm
-                                                               :form  {:id 99 :to-many true :value 1 :leaves [[:leaf 3] [:leaf 4]]}}
-                                                              {:ident [:leaf 3]
-                                                               :class LeafForm
-                                                               :form  {:id 3 :value 1 :leaf true}}
-                                                              {:ident [:leaf 4]
-                                                               :class LeafForm
-                                                               :form  {:id 4 :value 1 :leaf true}}]))
+    (f/get-forms tomany-form-db ToManyForm [:tomform 99])
+    => [{:ident [:tomform 99]
+         :class ToManyForm
+         :form  {:id 99 :to-many true :value 1 :leaves [[:leaf 3] [:leaf 4]]}}
+        {:ident [:leaf 3]
+         :class LeafForm
+         :form  {:id 3 :value 1 :leaf true}}
+        {:ident [:leaf 4]
+         :class LeafForm
+         :form  {:id 4 :value 1 :leaf true}}]))

 (specification "update-forms"
   (let [state (f/init-form nested-form-db Level3Form [:level3 1])
@@ -411,7 +418,7 @@
       (f/reduce-forms state form (fn [acc spec] (+ acc (get-in spec [:form :value]))) 0)) => 3))

 (specification "Form config and state helpers"
-  (let [ident-under-test [:people/by-id 1]
+  (let [ident-under-test [:people/by-id 7]
         app-state (f/init-form person-db Person ident-under-test)
         person-form (get-in app-state ident-under-test)]
     (assertions
@@ -508,13 +515,13 @@
 (let [app-state (-> person-db
                   (f/init-form Phone [:phone/by-id 1])
                   (f/init-form Phone [:phone/by-id 2])
-                  (f/init-form Person [:people/by-id 1])
+                  (f/init-form Person [:people/by-id 7])
                   (f/init-form Person [:people/by-id 3])
                   (f/init-form PolyPerson [:people/by-id 4])
                   (f/init-form PolyPerson [:people/by-id 5])
                   (f/init-form PolyPerson [:people/by-id 6]))
       basic-person (get-in app-state [:people/by-id 3])
-      one-number-person (get-in app-state [:people/by-id 1])
+      one-number-person (get-in app-state [:people/by-id 7])
       no-number-person (get-in app-state [:people/by-id 5])
       many-number-person (get-in app-state [:people/by-id 4])
       one-many-number-person (get-in app-state [:people/by-id 6])
@@ -621,6 +628,8 @@
               => true))))
       (component "commit-state - helper"
         (assertions
+          (f/get-original-data basic-person :person/name)
+          =fn=> #(not= % "MCQ")
           (-> basic-person
             (assoc :person/name "MCQ")
             (f/commit-state)


add trace output for test failure

add trace output for test failure

--- test/clj_money/web/transactions_test.clj
+++ test/clj_money/web/transactions_test.clj
@@ -128,4 +128,10 @@
                      :amount (bigdec 1001)
                      :balance (bigdec 1001)
                      :index 0}]}]
+
+    (when (not= expected actual)
+      (pprint {:expected expected
+               :actual actual
+               :diff (diff expected actual)}))
+
     (is (= expected actual) "The updated transaction can be retrieved")))


Fix malli tests

Fix malli tests

--- test/cljc/reitit/ring_coercion_test.cljc
+++ test/cljc/reitit/ring_coercion_test.cljc
@@ -305,7 +305,7 @@
                      (app (->request "open")))))))

         (testing "when schemas are not closed"
-          (let [app (->app {:compile identity})]
+          (let [app (->app {:compile (fn [v _] v)})]

             (testing "default: keys are stripped"
               (is (= {:status 200, :body {:x 1}}
@@ -320,7 +320,7 @@
                      (app (->request "open")))))))

         (testing "when schemas are not closed and extra keys are not stripped"
-          (let [app (->app {:compile identity, :strip-extra-keys false})]
+          (let [app (->app {:compile (fn [v _] v) :strip-extra-keys false})]
             (testing "default: keys are NOT stripped"
               (is (= {:status 200, :body {:x 1, :request true, :response true}}
                      (app (->request "default")))))


better full screen behavior for multiple monitors on mac

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

--- plugins/SlideExplorer2/src/slide_explorer/user_controls.clj
+++ plugins/SlideExplorer2/src/slide_explorer/user_controls.clj
@@ -57,19 +57,24 @@

 ;; full screen

-(defn- screen-devices []
+(defn screen-devices []
   (seq (.. java.awt.GraphicsEnvironment
       getLocalGraphicsEnvironment
       getScreenDevices)))

-(defn- screen-bounds [screen]
+(defn default-screen-device []
+  (.. java.awt.GraphicsEnvironment
+      getLocalGraphicsEnvironment
+      getDefaultScreenDevice))
+
+(defn screen-bounds [screen]
   (.. screen getDefaultConfiguration getBounds))

 (defn- overlap-area [rect1 rect2]
   (let [intersection (.intersection rect1 rect2)]
     (* (.height intersection) (.width intersection))))

-(defn- window-screen [window]
+(defn window-screen [window]
   (when window
     (let [window-bounds (.getBounds window)
           screens (screen-devices)]
@@ -87,7 +92,8 @@
     (.dispose window)
     (.setUndecorated window true)
     (let [screen (window-screen window)]
-      (if (JavaUtils/isMac)
+      (if (and (JavaUtils/isMac)
+               (= screen (default-screen-device)))
         (.setFullScreenWindow screen window)
         (.setBounds window (screen-bounds screen))))
     (.repaint window)
@@ -100,8 +106,9 @@
   (when (and window (@old-bounds window))
     (.dispose window)
     (.setUndecorated window false)
-    (when (JavaUtils/isMac)
-      (.setFullScreenWindow (window-screen window) nil))
+    (let [screen (window-screen window)]
+      (when (= window (.getFullScreenWindow screen))
+        (.setFullScreenWindow screen nil)))
     (when-let [bounds (@old-bounds window)]
       (.setBounds window bounds)
       (swap! old-bounds dissoc window))


y is m x 1 not n x 1.

y is m x 1 not n x 1.

--- project/analyze-data/src/analyze_data/naive_bayes/train.clj
+++ project/analyze-data/src/analyze_data/naive_bayes/train.clj
@@ -66,7 +66,7 @@
        --x(m)--]
       where each x(i) is a vector of length n
       thus m is the number of samples and n is the number of terms
-   y: n x 1 vector of class labels, which must be integers
+   y: m x 1 vector of class labels, which must be integers

   Return a map with keys :log-phi and :log-phi-y.
   :log-phi is a k x n matrix where k is the number of class labels and n is


Fix resource-namespaces function call

Fix resource-namespaces function call

--- cimi/src/com/sixsq/slipstream/ssclj/resources/common/dynamic_load.clj
+++ cimi/src/com/sixsq/slipstream/ssclj/resources/common/dynamic_load.clj
@@ -62,5 +62,5 @@
 (defn initialize
   "Runs the initialize function for all resources that define it."
   []
-  (doseq [resource-namespace resource-namespaces]
+  (doseq [resource-namespace (resource-namespaces)]
     (initialize-resource resource-namespace)))


Fixes virtual product test.

Fixes virtual product test.

I should have (reset), (run-all-tests)'ed when I merely C-c C-k, C-c M-,'ed.

--- system-int-test/test/cmr/system_int_test/bootstrap/virtual_products_test.clj
+++ system-int-test/test/cmr/system_int_test/bootstrap/virtual_products_test.clj
@@ -1,4 +1,4 @@
-(ns cmr.system-int-test.bootstrap.virtual-product-bootstrap-test
+(ns cmr.system-int-test.bootstrap.virtual-products-test
   (:require [clojure.test :refer :all]
             [cmr.system-int-test.data2.collection :as dc]
             [cmr.system-int-test.data2.core :as d]


CMR-4549 adds comment

CMR-4549 adds comment

--- umm-lib/test/cmr/umm/test/related_url_helper.clj
+++ umm-lib/test/cmr/umm/test/related_url_helper.clj
@@ -16,6 +16,7 @@
           documentation-url (umm-c/map->RelatedURL
                               {:type "VIEW RELATED INFORMATION"
                                :sub-type "USER'S GUIDE"
+                               ;; CMR-4549 test if mime-type check is case insensitive.
                                :mime-type "TeXt/HtMl"
                                :url "http://ghrc.nsstc.nasa.gov/uso/ds_docs/camex3/dc8capac/dc8capac_dataset.html"})
           metadata-url (umm-c/map->RelatedURL


Add debug output for websockets.

Add debug output for websockets.

This is to help suss out occasional integ failures in EAP.

--- web/test-integration/immutant/web/integ_test.clj
+++ web/test-integration/immutant/web/integ_test.clj
@@ -453,7 +453,13 @@
                           (async/send! ch "biscuit"
                             {:close? true
                              :on-success #(deliver @client-state :complete!)
-                             :on-error #(deliver @client-state %)})))))]
+                             :on-error (fn [e]
+                                         (println "SEND ERROR send!-a-string")
+                                         (.printStackTrace e)
+                                         (deliver @client-state e))}))
+               :on-error (fn [_ e]
+                           (println "CHANNEL ERROR send!-a-string")
+                           (.printStackTrace e)))))]
     (replace-handler handler)
     (is (= "biscuit" (get-body (cdef-url))))
     (is (= :complete! (read-string (get-body (str (cdef-url) "state")))))
@@ -476,7 +482,13 @@
                           (async/send! ch (.getBytes "biscuit")
                             {:close? true
                              :on-success #(deliver @client-state :complete!)
-                             :on-error #(deliver @client-state %)})))))]
+                             :on-error (fn [e]
+                                         (println "SEND ERROR send!-a-byte-array")
+                                         (.printStackTrace e)
+                                         (deliver @client-state e))}))
+               :on-error (fn [_ e]
+                           (println "CHANNEL ERROR send!-a-byte-array")
+                           (.printStackTrace e)))))]
     (replace-handler handler)
     (is (= "biscuit" (String. (get-body (cdef-url)))))
     (is (= :complete! (read-string (get-body (str (cdef-url) "state")))))
@@ -500,7 +512,13 @@
                           (async/send! ch (list "ham" (.getBytes "biscuit") (list "gravy"))
                             {:close? true
                              :on-success #(deliver @client-state :complete!)
-                             :on-error #(deliver @client-state %)})))))]
+                             :on-error (fn [e]
+                                         (println "SEND ERROR send!-a-sequence")
+                                         (.printStackTrace e)
+                                         (deliver @client-state e))}))
+               :on-error (fn [_ e]
+                           (println "CHANNEL ERROR send!-a-sequence")
+                           (.printStackTrace e)))))]
     (replace-handler handler)
     (is (= "hambiscuitgravy" (String. (get-body (cdef-url)))))
     (is (= :complete! (read-string (get-body (str (cdef-url) "state")))))
@@ -529,8 +547,15 @@
              (async/as-channel request
                :on-open (fn [ch]
                           (async/send! ch '()
-                            {:close? true}))
-               :on-close (fn [_ _] (deliver @client-state :complete!)))))]
+                            {:close? true
+                             :on-error (fn [e]
+                                         (println "SEND ERROR send!-an-empty-sequence")
+                                         (.printStackTrace e)
+                                         (deliver @client-state e))}))
+               :on-close (fn [_ _] (deliver @client-state :complete!))
+               :on-error (fn [_ e]
+                           (println "CHANNEL ERROR send!-an-empty-sequence")
+                           (.printStackTrace e)))))]
     (replace-handler handler)
     (get-body (cdef-url))
     (is (= :complete! (read-string (get-body (str (cdef-url) "state")))))
@@ -550,7 +575,13 @@
                           (async/send! ch (io/file (io/resource "public/foo.html"))
                             {:close? true
                              :on-success #(deliver @client-state :complete!)
-                             :on-error #(deliver @client-state %)})))))]
+                             :on-error (fn [e]
+                                         (println "SEND ERROR send!-a-file")
+                                         (.printStackTrace e)
+                                         (deliver @client-state e))}))
+               :on-error (fn [_ e]
+                           (println "CHANNEL ERROR send!-a-file")
+                           (.printStackTrace e)))))]
     (replace-handler handler)
     (is (= (slurp (io/file (io/resource "public/foo.html")))
           (String. (get-body (cdef-url)))))
@@ -578,7 +609,13 @@
                                             io/resource io/file)
                             {:close? true
                              :on-success #(deliver @client-state :complete!)
-                             :on-error #(deliver @client-state %)})))))
+                             :on-error (fn [e]
+                                         (println "SEND ERROR send!-with-input-stream-larger-than-size-hint")
+                                         (.printStackTrace e)
+                                         (deliver @client-state e))}))
+               :on-error (fn [_ e]
+                           (println "CHANNEL ERROR send!-with-input-stream-larger-than-size-hint")
+                           (.printStackTrace e)))))
         data (->> "data"
                io/resource io/file slurp)]
     (replace-handler handler)


joy working with macros

joy working with macros

--- src/clojure_learning/with-clojure-playing-chap-8-macros.clj
+++ src/clojure_learning/with-clojure-playing-chap-8-macros.clj
@@ -2,27 +2,16 @@

 (doc nnext)

-(do-until (even? 2) (println "even 2")
-          (odd? 3) (println "odd 3")
-          (zero? 1) (println "not printed")
-          (nil? 1) (println "not printed! nil"))
+;; introducing the custom [do-until] macro
+;; how to use the do-until macro:
+(do-until true (println "some") true (println "none") false (println "nil"))

-(defmacro do-until
-  [& clauses]
-  (list 'clojure.core/when (first clauses)
-        (if (next clauses)
-          (second clauses)
-          (throw (IllegalArgumentException. "do-until requires an even number of forms")))
-        (cons 'do-until (nnext clauses))))
-
-(defmacro do-until
-  [& clauses]
-  (if (even? (count clauses))
-    (let [[head-clause action-clause & tail-clauses] clauses]
-         (list 'clojure.core/when head-clause action-clause)
-        (if (not (empty? tail-clauses))
-          (cons 'do-until tail-clauses)))
-    (throw (IllegalArgumentException. "do-until requires an even number of forms"))))
+(defmacro do-until [& clauses]
+    (when clauses
+      (list 'when (first clauses)
+               (if (next clauses)  ;; check for existence? else fail-fast
+                   (second clauses)
+                   (throw (IllegalArgumentException. "do-until should have a pair of forms")))
+            (cons 'do-until (nnext clauses)))))

-


Set ns, pass compilter state to require

Set ns, pass compilter state to require

--- ClojureScript/planck/src/planck/core.cljs
+++ ClojureScript/planck/src/planck/core.cljs
@@ -112,7 +112,7 @@
 (defn require [args]
   #_(prn "require" args)
   (cljs.js/require
-    {:*compiler*     (env/default-compiler-env)
+    {:*compiler*     st
      :*data-readers* tags/*cljs-data-readers*
      :*load-fn*      load
      :*eval-fn*      eval}
@@ -122,7 +122,6 @@
       #_(println "require result:" res))))

 (defn ^:export read-eval-print [line]
-  (println "hi")
   (binding [ana/*cljs-ns* @current-ns
             *ns* (create-ns @current-ns)
             r/*data-readers* tags/*cljs-data-readers*]
@@ -143,7 +142,8 @@
           st
           line
           nil
-          {:load          load
+          {:ns            @current-ns
+           :load          load
            :eval          eval
            :verbose       true
            :context       :expr


add prerequisite to Cerebral Cast, have Sub Boost update ICE strength

--- src/clj/game/cards-operations.clj
+++ src/clj/game/cards-operations.clj
@@ -147,7 +147,8 @@
     :effect (effect (gain :credit (* 2 (count targets))))}

    "Cerebral Cast"
-   {:psi {:not-equal {:player :runner :prompt "Take 1 tag or 1 brain damage?"
+   {:req (req (:successful-run runner-reg))
+    :psi {:not-equal {:player :runner :prompt "Take 1 tag or 1 brain damage?"
                       :choices ["1 tag" "1 brain damage"] :msg (msg "give the Runner " target)
                       :effect (req (if (= target "1 tag")
                                      (tag-runner state side 1)
@@ -488,6 +489,7 @@
                                                 (concat ["Barrier"])
                                                 distinct
                                                 (join " - "))))
+                    (update-ice-strength target)
                     (host (get-card state target) (assoc card :zone [:discard] :seen true)))}

    "Subliminal Messaging"


Add set-properties, set-value and click-element to clojure.browser.dom.

--- src/cljs/clojure/browser/dom.cljs
+++ src/cljs/clojure/browser/dom.cljs
@@ -131,5 +131,20 @@
   [e]
   (.value (ensure-element e)))

+(defn set-properties
+  "Set properties on an element"
+  [e m]
+  (gdom/setProperties (ensure-element e)
+                      (.strobj m)))
+
+(defn set-value
+  "Set the value property for an element."
+  [e v]
+  (set-properties e {"value" v}))
+
+(defn click-element
+  [e]
+  (.click (ensure-element e) ()))
+
 ;; TODO CSS class manipulation
 ;; TODO Query syntax


add syntax highlighting for popular source file types

--- src/clojure/nightcode/editors.clj
+++ src/clojure/nightcode/editors.clj
@@ -224,19 +224,54 @@

 ; create and show/hide editors for each file

-(def ^:const styles {"clj" SyntaxConstants/SYNTAX_STYLE_CLOJURE
-                     "cljs" SyntaxConstants/SYNTAX_STYLE_CLOJURE
-                     "cljx" SyntaxConstants/SYNTAX_STYLE_CLOJURE
-                     "edn" SyntaxConstants/SYNTAX_STYLE_CLOJURE
-                     "js" SyntaxConstants/SYNTAX_STYLE_JAVASCRIPT
-                     "java" SyntaxConstants/SYNTAX_STYLE_JAVA
-                     "xml" SyntaxConstants/SYNTAX_STYLE_XML
-                     "html" SyntaxConstants/SYNTAX_STYLE_HTML
-                     "htm" SyntaxConstants/SYNTAX_STYLE_HTML
-                     "css" SyntaxConstants/SYNTAX_STYLE_CSS
-                     "json" SyntaxConstants/SYNTAX_STYLE_NONE
-                     "md" SyntaxConstants/SYNTAX_STYLE_NONE
-                     "txt" SyntaxConstants/SYNTAX_STYLE_NONE})
+(def ^:const styles {"as"         SyntaxConstants/SYNTAX_STYLE_ACTIONSCRIPT
+                     "asm"        SyntaxConstants/SYNTAX_STYLE_ASSEMBLER_X86
+                     "bat"        SyntaxConstants/SYNTAX_STYLE_WINDOWS_BATCH
+                     "BAT"        SyntaxConstants/SYNTAX_STYLE_WINDOWS_BATCH
+                     "c"          SyntaxConstants/SYNTAX_STYLE_C
+                     "cc"         SyntaxConstants/SYNTAX_STYLE_C
+                     "cl"         SyntaxConstants/SYNTAX_STYLE_LISP
+                     "cpp"        SyntaxConstants/SYNTAX_STYLE_CPLUSPLUS
+                     "css"        SyntaxConstants/SYNTAX_STYLE_CSS
+                     "clj"        SyntaxConstants/SYNTAX_STYLE_CLOJURE
+                     "cljs"       SyntaxConstants/SYNTAX_STYLE_CLOJURE
+                     "cljx"       SyntaxConstants/SYNTAX_STYLE_CLOJURE
+                     "cs"         SyntaxConstants/SYNTAX_STYLE_CSHARP
+                     "dtd"        SyntaxConstants/SYNTAX_STYLE_DTD
+                     "edn"        SyntaxConstants/SYNTAX_STYLE_CLOJURE
+                     "groovy"     SyntaxConstants/SYNTAX_STYLE_GROOVY
+                     "h"          SyntaxConstants/SYNTAX_STYLE_C
+                     "hpp"        SyntaxConstants/SYNTAX_STYLE_CPLUSPLUS
+                     "htm"        SyntaxConstants/SYNTAX_STYLE_HTML
+                     "html"       SyntaxConstants/SYNTAX_STYLE_HTML
+                     "java"       SyntaxConstants/SYNTAX_STYLE_JAVA
+                     "js"         SyntaxConstants/SYNTAX_STYLE_JAVASCRIPT
+                     "json"       SyntaxConstants/SYNTAX_STYLE_JAVASCRIPT
+                     "jsp"        SyntaxConstants/SYNTAX_STYLE_JSP
+                     "jspx"       SyntaxConstants/SYNTAX_STYLE_JSP
+                     "lisp"       SyntaxConstants/SYNTAX_STYLE_LISP
+                     "lua"        SyntaxConstants/SYNTAX_STYLE_LUA
+                     "makefile"   SyntaxConstants/SYNTAX_STYLE_MAKEFILE
+                     "Makefile"   SyntaxConstants/SYNTAX_STYLE_MAKEFILE
+                     "markdown"   SyntaxConstants/SYNTAX_STYLE_NONE
+                     "md"         SyntaxConstants/SYNTAX_STYLE_NONE
+                     "pas"        SyntaxConstants/SYNTAX_STYLE_DELPHI
+                     "properties" SyntaxConstants/SYNTAX_STYLE_PROPERTIES_FILE
+                     "php"        SyntaxConstants/SYNTAX_STYLE_PHP
+                     "pl"         SyntaxConstants/SYNTAX_STYLE_PERL
+                     "pm"         SyntaxConstants/SYNTAX_STYLE_PERL
+                     "py"         SyntaxConstants/SYNTAX_STYLE_PYTHON
+                     "rb"         SyntaxConstants/SYNTAX_STYLE_RUBY
+                     "s"          SyntaxConstants/SYNTAX_STYLE_ASSEMBLER_X86
+                     "sbt"        SyntaxConstants/SYNTAX_STYLE_SCALA
+                     "scala"      SyntaxConstants/SYNTAX_STYLE_SCALA
+                     "sh"         SyntaxConstants/SYNTAX_STYLE_UNIX_SHELL
+                     "sql"        SyntaxConstants/SYNTAX_STYLE_SQL
+                     "tcl"        SyntaxConstants/SYNTAX_STYLE_TCL
+                     "tex"        SyntaxConstants/SYNTAX_STYLE_LATEX
+                     "txt"        SyntaxConstants/SYNTAX_STYLE_NONE
+                     "xhtml"      SyntaxConstants/SYNTAX_STYLE_XML
+                     "xml"        SyntaxConstants/SYNTAX_STYLE_XML})
 (def ^:const clojure-exts #{"clj" "cljs" "cljx" "edn"})
 (def ^:const wrap-exts #{"md" "txt"})


Allow connected google email to be displayed (#1925)

* Allow connected google email to be displayed

* spell stuff correctly

--- src-cljs/frontend/components/pages/user_settings/integrations.cljs
+++ src-cljs/frontend/components/pages/user_settings/integrations.cljs
@@ -43,7 +43,8 @@
                     [:div
                      [:p (if (code-identities? name)
                            (str "Build and deploy your " name " repositories.")
-                           (str "Sign in with " name "."))]
+                           (when-not identity
+                             (str "Sign in with " name ".")))]
                      [:p.connection-status
                       (if identity
                         (list "Connected to " (:identity/login identity) ".")
@@ -60,7 +61,7 @@
   (render [this]
     (let [{[github-identity] "github"
            [bitbucket-identity] "bitbucket"
-           [gmail-identity] "gmail"}
+           [google-identity] "google"}
           (group-by :identity/type
                     (-> (om-next/props this) :app/current-user :user/identities))]
       (html
@@ -82,7 +83,7 @@
                                    :type "google"
                                    :icon-path (common/icon-path "brand-google")
                                    :auth-url (google/auth-url)
-                                   :identity gmail-identity})))))]))))
+                                   :identity google-identity})))))]))))

 (dc/do
   (defcard github-card-disconnected


Rename local vars.

Rename local vars.

--- src/dsbdp/data_processing_dsl.clj
+++ src/dsbdp/data_processing_dsl.clj
@@ -71,11 +71,11 @@
   [input offset rules]
   (let [extracted-strings (reduce
                             (fn [v rule]
-                              (let [transf-fn (create-data-processing-sub-fn (second rule) input offset)
-                                    transf-ret-type (get-data-processing-sub-fn-ret-type (eval `(fn [~input ~offset] ~transf-fn)))]
-                                (conj v (if (= java.lang.String transf-ret-type)
-                                          `(str "\"" ~transf-fn "\"")
-                                          transf-fn))))
+                              (let [data-proc-sub-fn (create-data-processing-sub-fn (second rule) input offset)
+                                    data-proc-sub-fn-ret-type (get-data-processing-sub-fn-ret-type (eval `(fn [~input ~offset] ~data-proc-sub-fn)))]
+                                (conj v (if (= java.lang.String data-proc-sub-fn-ret-type)
+                                          `(str "\"" ~data-proc-sub-fn "\"")
+                                          data-proc-sub-fn))))
                             '[str] rules)
         commas (reduce into [] ["." (repeat (- (count rules) 1) ",") "."])]
     (vec (filter #(not= \. %) (interleave extracted-strings commas)))))
@@ -86,12 +86,12 @@
   (let [extracted-strings (conj
                             (reduce
                               (fn [v rule]
-                                (let [transf-fn (create-data-processing-sub-fn (second rule) input offset)
-                                      transf-ret-type (get-data-processing-sub-fn-ret-type (eval `(fn [~input ~offset] ~transf-fn)))]
+                                (let [data-proc-sub-fn (create-data-processing-sub-fn (second rule) input offset)
+                                      data-proc-sub-fn-ret-type (get-data-processing-sub-fn-ret-type (eval `(fn [~input ~offset] ~data-proc-sub-fn)))]
                                   (conj v "\"" (name (first rule)) "\":"
-                                          (if (= java.lang.String transf-ret-type)
-                                            `(str "\"" ~transf-fn "\"")
-                                            transf-fn))))
+                                          (if (= java.lang.String data-proc-sub-fn-ret-type)
+                                            `(str "\"" ~data-proc-sub-fn "\"")
+                                            data-proc-sub-fn))))
                               '[str "{"] rules)
                             "}")
         commas (reduce into [] ["." "." "." "." "." (reduce into [] (repeat (- (count rules) 1) ["," "." "." "."])) "." "."])]


get rid of stale imports

get rid of stale imports

--- src/er_cassandra/model/error.cljc
+++ src/er_cassandra/model/error.cljc
@@ -6,12 +6,7 @@
       :cljs [plumbing.core :refer [assoc-when]])
    #?(:clj [clojure.core.match :refer [match]]
       :cljs [cljs.core.match :refer-macros [match]])
-   [schema.core :as s #?@(:cljs [:include-macros true])]
-   [schema.coerce :refer [coercer]]
-   [er-model.schema
-    :refer [x-json-coercion-matcher
-            check-variant
-            check-map-variant]]))
+   [schema.core :as s #?@(:cljs [:include-macros true])]))

 ;; some functions for creating and collecting a log
 ;; of errors relating to an entity