Skip to content
Snippets Groups Projects
Commit 6a6cb3e8 authored by Arthur Ulfeldt's avatar Arthur Ulfeldt
Browse files

resync tables when visibility changes

parent 2d241f64
No related branches found
No related tags found
No related merge requests found
(ns metabase.api.table
"/api/table endpoints."
(:require [compojure.core :refer [GET PUT]]
(:require [clojure.tools.logging :as log]
[compojure.core :refer [GET PUT]]
[metabase
[sync-database :as sync-database]
[util :as u]]
[metabase.api.common :as api]
[metabase.models
[field :refer [Field]]
......@@ -44,15 +48,21 @@
entity_type (s/maybe TableEntityType)
visibility_type (s/maybe TableVisibilityType)}
(api/write-check Table id)
(api/check-500 (db/update-non-nil-keys! Table id
:display_name display_name
:caveats caveats
:points_of_interest points_of_interest
:show_in_getting_started show_in_getting_started
:entity_type entity_type
:description description))
(api/check-500 (db/update! Table id, :visibility_type visibility_type))
(Table id))
(let [original-visibility_type (:visibility_type (Table :id id))]
(api/check-500 (db/update-non-nil-keys! Table id
:display_name display_name
:caveats caveats
:points_of_interest points_of_interest
:show_in_getting_started show_in_getting_started
:entity_type entity_type
:description description))
(api/check-500 (db/update! Table id, :visibility_type visibility_type))
(let [updated-table (Table :id id)
visibility-changed? (not= (:visibility_type updated-table) original-visibility_type)]
(when visibility-changed?
(log/debug (u/format-color 'green "Table visibility changed, resyncing %s -> %s : %s") original-visibility_type visibility_type visibility-changed?)
(sync-database/sync-table! updated-table))
updated-table)))
(api/defendpoint GET "/:id/query_metadata"
......
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