Skip to content
Snippets Groups Projects
Unverified Commit ead957f7 authored by Cam Saul's avatar Cam Saul
Browse files

Merge branch 'release-0.33.x' into merge-release-0.33.x->master

parents ea5b6a6b 61e6bccb
Branches
Tags
No related merge requests found
......@@ -9,8 +9,6 @@
.DS_Store
.\#*
.eastwood
.eastwood
.idea/
.idea/
.nrepl-port
.vscode
......@@ -31,10 +29,12 @@
/classes
/coverage
/crate-*
/cypress
/deploy/artifacts/*
/docs/uberdoc.html
/lein-plugins/*/target
/local/src
/local/src
/locales/metabase-*.pot
/modules/drivers/*/target
/node_modules/
......@@ -43,9 +43,11 @@
/reset-password-artifacts
/resources/frontend_client/app/dist/
/resources/frontend_client/app/locales
/resources/frontend_client/app/locales
/resources/frontend_client/embed.html
/resources/frontend_client/index.html
/resources/frontend_client/public.html
/resources/namespaces.edn
/resources/sample-dataset.db.trace.db
/resources/version.properties
/screenshots
......@@ -67,8 +69,3 @@ profiles.clj
target/checksum.txt
xcshareddata
xcuserdata
/resources/frontend_client/app/locales
*.iml
.idea/
/local/src
/cypress
......@@ -10,6 +10,7 @@
[clojure.math.numeric-tower :as math]
[clojure.tools.logging :as log]
[clojure.tools.namespace.find :as ns-find]
[clojure.tools.reader.edn :as edn]
[colorize.core :as colorize]
[flatland.ordered.map :refer [ordered-map]]
[medley.core :as m]
......@@ -454,22 +455,36 @@
(or (id object-or-id)
(throw (Exception. (tru "Not something with an ID: {0}" object-or-id)))))
(defn- namespace-symbs* []
(for [ns-symb (ns-find/find-namespaces (concat (classpath/system-classpath)
(classpath/classpath (classloader/the-classloader))))
:when (and (.startsWith (name ns-symb) "metabase.")
(not (.contains (name ns-symb) "test")))]
ns-symb))
(defn- metabase-namespace-symbs* []
(vec (sort (for [ns-symb (ns-find/find-namespaces (classpath/system-classpath))
:when (and (.startsWith (name ns-symb) "metabase.")
(not (.contains (name ns-symb) "test")))]
ns-symb))))
(def ^:private namespace-symbs-filename "resources/namespaces.edn")
(when *compile-files*
(printf "Saving list of Metabase namespaces to %s...\n" namespace-symbs-filename)
(spit namespace-symbs-filename (with-out-str (pprint (metabase-namespace-symbs*)))))
(def metabase-namespace-symbols
"Delay to a vector of symbols of all Metabase namespaces, excluding test namespaces.
This is intended for use by various routines that load related namespaces, such as task and events initialization.
Using `ns-find/find-namespaces` is fairly slow, and can take as much as half a second to iterate over the thousand
or so namespaces that are part of the Metabase project; use this instead for a massive performance increase."
;; We want to give JARs in the ./plugins directory a chance to load. At one point we have this as a future so it
;; start looking for things in the background while other stuff is happening but that meant plugins couldn't
;; introduce new Metabase namespaces such as drivers.
(delay (vec (namespace-symbs*))))
"Delay to a vector of symbols of all Metabase namespaces, excluding test namespaces. This is intended for use by
various routines that load related namespaces, such as task and events initialization."
;; When building the uberjar we'll determine the symbols ahead of time ans save to an EDN file which will speed up
;; initialization a bit and also fix an issue where the sequence would be empty if `:omit-source` was enabled.
;; `ns-find` looks for Clojure source files.
;;
;; Use a delay for dev runs since `ns-find` is slow and can take several seconds or more
(if config/is-prod?
(delay
(try
(log/info (trs "Reading Metabase namespaces from {0}" namespace-symbs-filename))
(edn/read-string (slurp namespace-symbs-filename))
(catch Throwable e
(log/error e (trs "Failed to read Metabase namespaces from {0}" namespace-symbs-filename))
(metabase-namespace-symbs*))))
(delay
(metabase-namespace-symbs*))))
(def ^java.util.regex.Pattern uuid-regex
"A regular expression for matching canonical string representations of UUIDs."
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment