Skip to content
Snippets Groups Projects
Commit c1d6bc94 authored by lbrdnk's avatar lbrdnk
Browse files

Revert "Tweak some sheet around CSV uploads (#48000)"

This reverts commit 48aad35c.
parent c767579f
No related branches found
No related tags found
No related merge requests found
...@@ -181,7 +181,7 @@ ...@@ -181,7 +181,7 @@
"secrets" false "secrets" false
"success" true "success" true
"error_message" nil} "error_message" nil}
(-> (snowplow-test/pop-event-data-and-user-id!) last :data)))) (-> (snowplow-test/pop-event-data-and-user-id!) first :data))))
(testing "POST /api/ee/serialization/import" (testing "POST /api/ee/serialization/import"
(t2/update! :model/Card {:id (:id card)} {:name (str "qwe_" (:name card))}) (t2/update! :model/Card {:id (:id card)} {:name (str "qwe_" (:name card))})
...@@ -205,7 +205,7 @@ ...@@ -205,7 +205,7 @@
"error_count" 0 "error_count" 0
"success" true "success" true
"error_message" nil} "error_message" nil}
(-> (snowplow-test/pop-event-data-and-user-id!) last :data)))))) (-> (snowplow-test/pop-event-data-and-user-id!) first :data))))))
(mt/with-dynamic-redefs [v2.load/load-one! (let [load-one! (mt/dynamic-value #'v2.load/load-one!)] (mt/with-dynamic-redefs [v2.load/load-one! (let [load-one! (mt/dynamic-value #'v2.load/load-one!)]
(fn [ctx path & [modfn]] (fn [ctx path & [modfn]]
...@@ -222,6 +222,8 @@ ...@@ -222,6 +222,8 @@
{:file ba})) {:file ba}))
log (slurp (io/input-stream res))] log (slurp (io/input-stream res))]
(testing "3 header lines, then cards+database+collection, then the error" (testing "3 header lines, then cards+database+collection, then the error"
(is (= #{"Card" "Database" "Collection"}
(log-types (str/split-lines log))))
(is (re-find #"Failed to read file for Collection DoesNotExist" log)) (is (re-find #"Failed to read file for Collection DoesNotExist" log))
(is (re-find #"Cannot find file entry" log)) ;; underlying error (is (re-find #"Cannot find file entry" log)) ;; underlying error
(is (= {:deps-chain #{[{:id "**ID**", :model "Card"}]}, (is (= {:deps-chain #{[{:id "**ID**", :model "Card"}]},
...@@ -239,7 +241,7 @@ ...@@ -239,7 +241,7 @@
"count" 0 "count" 0
"error_count" 0 "error_count" 0
"error_message" #"(?s)Failed to read file for Collection DoesNotExist.*"} "error_message" #"(?s)Failed to read file for Collection DoesNotExist.*"}
(-> (snowplow-test/pop-event-data-and-user-id!) last :data)))))) (-> (snowplow-test/pop-event-data-and-user-id!) first :data))))))
(testing "Skipping errors /api/ee/serialization/import" (testing "Skipping errors /api/ee/serialization/import"
(let [res (mt/user-http-request :crowberto :post 200 "ee/serialization/import" (let [res (mt/user-http-request :crowberto :post 200 "ee/serialization/import"
...@@ -260,7 +262,7 @@ ...@@ -260,7 +262,7 @@
"count" 2 "count" 2
"error_count" 1 "error_count" 1
"models" "Collection,Dashboard"} "models" "Collection,Dashboard"}
(-> (snowplow-test/pop-event-data-and-user-id!) last :data)))))))) (-> (snowplow-test/pop-event-data-and-user-id!) first :data))))))))
(mt/with-dynamic-redefs [serdes/extract-one (extract-one-error (:entity_id card) (mt/with-dynamic-redefs [serdes/extract-one (extract-one-error (:entity_id card)
(mt/dynamic-value serdes/extract-one))] (mt/dynamic-value serdes/extract-one))]
...@@ -290,7 +292,7 @@ ...@@ -290,7 +292,7 @@
"secrets" false "secrets" false
"success" false "success" false
"error_message" #"(?s)Exception extracting Card \d+ .*"} "error_message" #"(?s)Exception extracting Card \d+ .*"}
(-> (snowplow-test/pop-event-data-and-user-id!) last :data)))) (-> (snowplow-test/pop-event-data-and-user-id!) first :data))))
(testing "Full stacktrace" (testing "Full stacktrace"
(binding [api.serialization/*additive-logging* false] (binding [api.serialization/*additive-logging* false]
...@@ -331,7 +333,7 @@ ...@@ -331,7 +333,7 @@
"secrets" false "secrets" false
"success" true "success" true
"error_message" nil} "error_message" nil}
(-> (snowplow-test/pop-event-data-and-user-id!) last :data)))))) (-> (snowplow-test/pop-event-data-and-user-id!) first :data))))))
(testing "Only admins can export/import" (testing "Only admins can export/import"
(is (= "You don't have permissions to do that." (is (= "You don't have permissions to do that."
......
...@@ -888,9 +888,8 @@ ...@@ -888,9 +888,8 @@
:db-id (or (:db_id uploads-db-settings) :db-id (or (:db_id uploads-db-settings)
(throw (ex-info (tru "The uploads database is not configured.") (throw (ex-info (tru "The uploads database is not configured.")
{:status-code 422})))})] {:status-code 422})))})]
{:status 200 {:status 200
:body (:id model) :body (:id model)})
:headers {"metabase-table-id" (str (:table-id model))}})
(catch Throwable e (catch Throwable e
{:status (or (-> e ex-data :status-code) {:status (or (-> e ex-data :status-code)
500) 500)
......
...@@ -8,11 +8,7 @@ ...@@ -8,11 +8,7 @@
[metabase.search.impl :as search.impl] [metabase.search.impl :as search.impl]
[metabase.search.postgres.index :as search.index] [metabase.search.postgres.index :as search.index]
[metabase.search.postgres.ingestion :as search.ingestion] [metabase.search.postgres.ingestion :as search.ingestion]
[toucan2.core :as t2]) [toucan2.core :as t2]))
(:import
(java.time OffsetDateTime)))
(set! *warn-on-reflection* true)
(defn- user-params [search-ctx] (defn- user-params [search-ctx]
(cond (cond
...@@ -83,10 +79,6 @@ ...@@ -83,10 +79,6 @@
(t2/query <>) (t2/query <>)
(filter (comp (set ids) :id) <>))))))) (filter (comp (set ids) :id) <>)))))))
(defn- parse-datetime [s]
(when s
(OffsetDateTime/parse s)))
(defn- minimal [search-term & {:as _search-ctx}] (defn- minimal [search-term & {:as _search-ctx}]
(when-not @#'search.index/initialized? (when-not @#'search.index/initialized?
(throw (ex-info "Search index is not initialized. Use [[init!]] to ensure it exists." (throw (ex-info "Search index is not initialized. Use [[init!]] to ensure it exists."
...@@ -94,11 +86,7 @@ ...@@ -94,11 +86,7 @@
(->> (assoc (search.index/search-query search-term) :select [:legacy_input]) (->> (assoc (search.index/search-query search-term) :select [:legacy_input])
(t2/query) (t2/query)
(map :legacy_input) (map :legacy_input)
(map #(json/parse-string % keyword)) (map #(json/parse-string % keyword))))
(map #(-> %
(update :created_at parse-datetime)
(update :updated_at parse-datetime)
(update :last_edited_at parse-datetime)))))
(def ^:private default-engine hybrid-multi) (def ^:private default-engine hybrid-multi)
......
...@@ -633,7 +633,7 @@ ...@@ -633,7 +633,7 @@
(assoc stats (assoc stats
:event :csv-upload-successful :event :csv-upload-successful
:model-id (:id card))) :model-id (:id card)))
(assoc card :table-id (:id table))) card)
(catch Throwable e (catch Throwable e
(snowplow/track-event! ::snowplow/csvupload (assoc (fail-stats filename file) (snowplow/track-event! ::snowplow/csvupload (assoc (fail-stats filename file)
:event :csv-upload-failed)) :event :csv-upload-failed))
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
"d MMMM, uuuu" ; 30 January, 2000 "d MMMM, uuuu" ; 30 January, 2000
"EEEE, MMMM d uuuu" ; Sunday, January 30 2000 "EEEE, MMMM d uuuu" ; Sunday, January 30 2000
"EEEE, MMMM d, uuuu" ; Sunday, January 30, 2000 "EEEE, MMMM d, uuuu" ; Sunday, January 30, 2000
"EEE MMM dd uuuu HH:mm:ss 'GMT'Z (zzzz)" ; The format produced by exporting Google Sheets
]) ])
(def local-date-formatter (def local-date-formatter
......
...@@ -58,11 +58,14 @@ ...@@ -58,11 +58,14 @@
(is (= (hybrid term) (is (= (hybrid term)
(hybrid-multi term)))))))) (hybrid-multi term))))))))
(defn- remove-time [m]
(dissoc m :created_at :updated_at :last_edited_at))
(deftest minimal-test (deftest minimal-test
(with-setup (with-setup
(testing "consistent results between both hybrid implementations\n" (testing "consistent results between both hybrid implementations\n"
(doseq [term example-terms] (doseq [term example-terms]
(testing term (testing term
;; Timestamps are not strings after round trip, but this doesn't matter ;; Timestamps are not strings after round trip, but this doesn't matter
(is (= (hybrid term) (is (= (map remove-time (hybrid term))
(minimal term)))))))) (map remove-time (minimal term)))))))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment