Skip to content
Snippets Groups Projects
Unverified Commit 0adadc9a authored by github-automation-metabase's avatar github-automation-metabase Committed by GitHub
Browse files

Send separate events for CSV appending and replacing (#50525) (#50553)

parent 77b70d05
No related branches found
No related tags found
No related merge requests found
......@@ -212,6 +212,7 @@
(derive ::upload-event ::event)
(derive :event/upload-create ::upload-event)
(derive :event/upload-append ::upload-event)
(derive :event/upload-replace ::upload-event)
(methodical/defmethod events/publish-event! ::upload-event
[topic event]
......
......@@ -807,7 +807,9 @@
(invalidate-cached-models! table)
(events/publish-event! :event/upload-append
(events/publish-event! (if replace-rows?
:event/upload-replace
:event/upload-append)
{:user-id (:id @api/*current-user*)
:model-id (:id table)
:model :model/Table
......
......@@ -1823,11 +1823,15 @@
(testing (action-testing-str action)
(mt/with-premium-features #{:audit-app}
(with-upload-table! [table (create-upload-table!)]
(let [csv-rows ["name" "Luke Skywalker"]
file (csv-file-with csv-rows)]
(let [csv-rows ["name" "Luke Skywalker"]
file (csv-file-with csv-rows)
event-type (case action
::upload/append :upload-append
::upload/replace :upload-replace)]
(update-csv! action {:file file, :table-id (:id table)})
(is (=? {:topic :upload-append
(is (=? {:topic event-type
:user_id (:id (mt/fetch-user :crowberto))
:model "Table"
:model_id (:id table)
......@@ -1839,7 +1843,7 @@
:generated-columns 0
:size-mb 1.811981201171875E-5
:upload-seconds pos?}}}
(last-audit-event :upload-append)))
(last-audit-event event-type)))
(io/delete-file file))))))))
......
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