Skip to content
Snippets Groups Projects
Commit 85ffb7a4 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

simply sync the sample dataset on app startup, but explicitly skip any...

simply sync the sample dataset on app startup, but explicitly skip any activity feed entries related to the sample dataset.
parent 6abcb4a9
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@
[metabase.events :as events]
(metabase.models [activity :refer [Activity]]
[dashboard :refer [Dashboard]]
[database :refer [Database]]
[session :refer [Session]])))
......@@ -79,17 +80,20 @@
:dashboard-remove-cards (record-activity topic object add-remove-card-details))))
(defn- process-database-activity [topic object]
(let [database-details-fn (fn [obj] (-> obj
(let [database (db/sel :one Database :id (events/object->model-id topic object))
database-details-fn (fn [obj] (-> obj
(assoc :status "started")
(dissoc :database_id :custom_id)))
database-table-fn (fn [obj] {:database-id (events/object->model-id topic obj)})]
(case topic
:database-sync-begin (record-activity :database-sync object database-details-fn database-table-fn)
:database-sync-end (let [{activity-id :id} (db/sel :one Activity :custom_id (:custom_id object))]
(db/upd Activity activity-id
:details (-> object
(assoc :status "completed")
(dissoc :database_id :custom_id)))))))
database-table-fn (fn [obj] {:database-id (events/object->model-id topic obj)})]
;; NOTE: we are skipping any handling of activity for sample databases
(when (= false (:is_sample database))
(case topic
:database-sync-begin (record-activity :database-sync object database-details-fn database-table-fn)
:database-sync-end (let [{activity-id :id} (db/sel :one Activity :custom_id (:custom_id object))]
(db/upd Activity activity-id
:details (-> object
(assoc :status "completed")
(dissoc :database_id :custom_id))))))))
(defn- process-user-activity [topic object]
;; we only care about login activity when its the users first session (a.k.a. new user!)
......
......@@ -32,6 +32,6 @@
(log/error (format "Failed to load sample dataset: %s" (.getMessage e)))))))
(defn update-sample-dataset-if-needed! []
;; TODO - fill this out
;; NOTE: we don't want to sync the sample dataset unless it has actually changed
nil)
;; TODO - it would be a bit nicer if we skipped this when the data hasn't changed
(when-let [db (db/sel :one Database :is_sample true)]
(driver/sync-database! db)))
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