Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
f2455669
Unverified
Commit
f2455669
authored
7 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Revert code accidentally removed in #5794
parent
4c41b0a6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/driver/googleanalytics.clj
+36
-1
36 additions, 1 deletion
src/metabase/driver/googleanalytics.clj
with
36 additions
and
1 deletion
src/metabase/driver/googleanalytics.clj
+
36
−
1
View file @
f2455669
...
...
@@ -50,6 +50,7 @@
(
.getId
profile
))))
(
defn-
describe-database
[
database
]
;; Include a `_metabase_metadata` table in the list of Tables so we can provide custom metadata. See below.
{
:tables
(
set
(
for
[
table-id
(
cons
"_metabase_metadata"
(
profile-ids
database
))]
{
:name
table-id
:schema
nil
}))})
...
...
@@ -115,6 +116,39 @@
:fields
(
describe-columns
database
)})
;;; ----------------------------------------------- _metabase_metadata -----------------------------------------------
;; The following is provided so we can specify custom display_names for Tables and Fields since there's not yet a way
;; to do it directly in `describe-database` or `describe-table`. Just fake results for the Table in `table-rows-seq`
;; (rows in `_metabase_metadata` are just property -> value, e.g. `<table>.display_name` -> `<display-name>`.)
(
defn-
property+profile->display-name
"Format a table name for a GA property and GA profile"
[
^
Webproperty
property,
^
Profile
profile
]
(
let
[
property-name
(
s/replace
(
.getName
property
)
#
"^https?://"
""
)
profile-name
(
s/replace
(
.getName
profile
)
#
"^https?://"
""
)]
;; don't include the profile if it's the same as property-name or is the default "All Web Site Data"
(
if
(
or
(
.contains
property-name
profile-name
)
(
=
profile-name
"All Web Site Data"
))
property-name
(
str
property-name
" ("
profile-name
")"
))))
(
defn-
table-rows-seq
[
database
table
]
;; this method is only supposed to be called for _metabase_metadata, make sure that's the case
{
:pre
[(
=
(
:name
table
)
"_metabase_metadata"
)]}
;; now build a giant sequence of all the things we want to set
(
apply
concat
;; set display_name for all the tables
(
for
[[
^
Webproperty
property,
^
Profile
profile
]
(
properties+profiles
database
)]
(
cons
{
:keypath
(
str
(
.getId
profile
)
".display_name"
)
:value
(
property+profile->display-name
property
profile
)}
;; set display_name and description for each column for this table
(
apply
concat
(
for
[
^
Column
column
(
columns
database
)]
[{
:keypath
(
str
(
.getId
profile
)
\.
(
.getId
column
)
".display_name"
)
:value
(
column-attribute
column
:uiName
)}
{
:keypath
(
str
(
.getId
profile
)
\.
(
.getId
column
)
".description"
)
:value
(
column-attribute
column
:description
)}]))))))
;;; -------------------------------------------------- can-connect? --------------------------------------------------
...
...
@@ -217,7 +251,8 @@
:required
true
}])
:execute-query
(
u/drop-first-arg
(
partial
qp/execute-query
do-query
))
:process-query-in-context
(
u/drop-first-arg
process-query-in-context
)
:mbql->native
(
u/drop-first-arg
qp/mbql->native
)}))
:mbql->native
(
u/drop-first-arg
qp/mbql->native
)
:table-rows-seq
(
u/drop-first-arg
table-rows-seq
)}))
(
defn
-init-driver
"Register the Google Analytics driver"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment