diff --git a/.clj-kondo/config.edn b/.clj-kondo/config.edn index 571e65aa2519c9668aaf7713e0689979ccb3167e..f9b37e3a08e6600d089eff564ac1a32ec6572602 100644 --- a/.clj-kondo/config.edn +++ b/.clj-kondo/config.edn @@ -175,7 +175,7 @@ metabase.db.query ; TODO this is mostly util stuff like `metabase.db.query/query` that we don't even need anymore. metabase.db.setup} ; TODO these are only calling `metabase.db.setup/setup-db!` and there's a slightly different version in `metabase.db` metabase.domain-entities #{metabase.domain-entities.core - metabase.domain-entities.specs} ; TODO -- consolidate these into a real API namespace. + metabase.domain-entities.specs} ; TODO -- these should probably be combined into the `metabase.transforms` module, that's the only place that uses them. metabase.driver :any ; TODO -- 19 namespaces!!!! CRY metabase.email #{metabase.email metabase.email.messages} ; TODO -- consolidate these into a real API namespace. @@ -193,9 +193,7 @@ metabase.legacy-mbql.util} ; TODO -- consolidate these into a real API namespace. metabase.lib :any ; TODO -- :cry: 34 externally referenced namespaces, but maybe half of them are schema namespaces which technically don't need to be required. metabase.logger #{metabase.logger} - metabase.metabot #{metabase.metabot - metabase.metabot.feedback - metabase.metabot.util} ; TODO -- consolidate these into a real API namespace. + metabase.metabot #{metabase.metabot} metabase.models :any ; TODO -- scream, 62 namespaces used elsewhere, but to be fair a lot of these don't *need* to be required. metabase.moderation #{metabase.moderation} metabase.native-query-analyzer #{metabase.native-query-analyzer} diff --git a/.clj-kondo/hooks/clojure/core.clj b/.clj-kondo/hooks/clojure/core.clj index 0947b7b8c8f58a210ef4dd81c1e6c797e2123a5b..af9e7304c6a9c8c09c91c8b6ca3b7bd6f45940a9 100644 --- a/.clj-kondo/hooks/clojure/core.clj +++ b/.clj-kondo/hooks/clojure/core.clj @@ -298,7 +298,7 @@ :when (not (contains? clj-kondo-ignore :metabase/ns-module-checker)) :let [required-namespace (hooks/sexpr node) required-module (module required-namespace)] - ;; ignore stuff not in a module i.e. non-Metabase stuff. + ;; ignore stuff not in a module i.e. non-Metabase stuff. :when required-module :let [in-current-module? (= required-module current-module)] :when (not in-current-module?) diff --git a/src/metabase/api/metabot.clj b/src/metabase/api/metabot.clj index f58a802c2ee9f20bb9c7a0a994d6b5c2760babf9..951437a2d67f982e32378d53cced54bfdf70c88c 100644 --- a/src/metabase/api/metabot.clj +++ b/src/metabase/api/metabot.clj @@ -5,8 +5,6 @@ [compojure.core :refer [POST]] [metabase.api.common :as api] [metabase.metabot :as metabot] - [metabase.metabot.feedback :as metabot-feedback] - [metabase.metabot.util :as metabot-util] [metabase.models :refer [Card Database]] [metabase.util.log :as log] [metabase.util.malli.schema :as ms] @@ -17,7 +15,7 @@ (defn- check-database-support "Do a preliminary check to ensure metabot will work. Throw an exception if not." [database-id] - (when-not (metabot-util/supported? database-id) + (when-not (metabot/supported? database-id) (throw (let [message "Metabot is not supported for this database type."] (ex-info @@ -59,7 +57,7 @@ question) (let [model (api/check-404 (t2/select-one Card :id model-id :type :model)) _ (check-database-support (:database_id model)) - context {:model (metabot-util/denormalize-model model) + context {:model (metabot/denormalize-model model) :user_prompt question :prompt_task :infer_sql} dataset (infer-sql-or-throw context question)] @@ -76,7 +74,7 @@ question) (let [{:as database} (api/check-404 (t2/select-one Database :id database-id)) _ (check-database-support (:id database)) - context {:database (metabot-util/denormalize-database database) + context {:database (metabot/denormalize-database database) :user_prompt question :prompt_task :infer_model}] (if-some [model (metabot/infer-model context)] @@ -106,7 +104,7 @@ question) (let [{:as database} (api/check-404 (t2/select-one Database :id database-id)) _ (check-database-support (:id database)) - context {:database (metabot-util/denormalize-database database) + context {:database (metabot/denormalize-database database) :user_prompt question :prompt_task :infer_native_sql}] (metabot/infer-native-sql-query context))) @@ -114,7 +112,7 @@ (api/defendpoint POST "/feedback" "Record feedback on metabot results." [:as {feedback :body}] - (if-some [stored-feedback (metabot-feedback/submit-feedback feedback)] + (if-some [stored-feedback (metabot/submit-feedback feedback)] {:feedback stored-feedback :message "Thanks for your feedback"} (throw diff --git a/src/metabase/metabot.clj b/src/metabase/metabot.clj index e144d4f5457cc67f1b6fdc71f2d49d015ff7b96e..a64cb1ea06a3002b495f6f35f1b1165fb7c60fca 100644 --- a/src/metabase/metabot.clj +++ b/src/metabase/metabot.clj @@ -5,12 +5,25 @@ [cheshire.core :as json] [metabase.lib.native :as lib-native] [metabase.metabot.client :as metabot-client] + [metabase.metabot.feedback :as metabot-feedback] [metabase.metabot.settings :as metabot-settings] [metabase.metabot.util :as metabot-util] [metabase.models :refer [Table]] [metabase.util.log :as log] + [potemkin :as p] [toucan2.core :as t2])) +(comment metabot-feedback/keep-me + metabot-util/keep-me) + +(p/import-vars + [metabot-feedback + submit-feedback] + [metabot-util + denormalize-database + denormalize-model + supported?]) + (defn infer-viz "Determine an 'interesting' visualization for this data." [{sql :sql :as context}] diff --git a/src/metabase/metabot/feedback.clj b/src/metabase/metabot/feedback.clj index b2a4cbb3ce9b70a40381224fcf7433824a69d5cf..327af6aef44f5668df735597d98e639db402565a 100644 --- a/src/metabase/metabot/feedback.clj +++ b/src/metabase/metabot/feedback.clj @@ -1,9 +1,10 @@ (ns metabase.metabot.feedback - (:require [cheshire.core :as json] - [clj-http.client :as http] - [metabase.analytics.snowplow :as snowplow] - [metabase.api.common :as api] - [metabase.metabot.settings :as metabot-settings])) + (:require + [cheshire.core :as json] + [clj-http.client :as http] + [metabase.analytics.snowplow :as snowplow] + [metabase.api.common :as api] + [metabase.metabot.settings :as metabot-settings])) (def ^:private snowplow-keys [:entity_type :prompt_template_versions :feedback_type]) (def ^:private feedback-keys (into snowplow-keys [:prompt :sql]))