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
1f6a9022
Unverified
Commit
1f6a9022
authored
6 years ago
by
Simon Belak
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #9488 from metabase/xray-better-interesting-filters
Make xray dashboard filters more diverse
parents
44c10681
0e0700a5
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/automagic_dashboards/core.clj
+3
-3
3 additions, 3 deletions
src/metabase/automagic_dashboards/core.clj
src/metabase/automagic_dashboards/filters.clj
+20
-9
20 additions, 9 deletions
src/metabase/automagic_dashboards/filters.clj
with
23 additions
and
12 deletions
src/metabase/automagic_dashboards/core.clj
+
3
−
3
View file @
1f6a9022
...
...
@@ -1123,14 +1123,14 @@
(
->>
field-reference
(
field-reference->field
root
)
field-name
))
([{
:keys
[
display_name
unit
]
:as
field
}]
(
cond->>
display_name
(
and
(
filters/periodic-datetime?
field
)
unit
)
(
tru
"{0} of {1}"
(
unit-name
unit
)))))
(
some->
unit
date/date-extract-
unit
s
)
(
tru
"{0} of {1}"
(
unit-name
unit
)))))
(
defmethod
humanize-filter-value
:=
[
root
[
_
field-reference
value
]]
(
let
[
field
(
field-reference->field
root
field-reference
)
field-name
(
field-name
field
)]
(
if
(
or
(
filters/d
ate
t
ime
?
field
)
(
fi
lters/periodic-datetime
?
field
))
(
if
(
or
(
isa?
(
:base_type
field
)
:type/D
ate
T
ime
)
(
fi
eld/unix-timestamp
?
field
))
(
tru
"{0} is {1}"
field-name
(
humanize-datetime
value
(
:unit
field
)))
(
tru
"{0} is {1}"
field-name
value
))))
...
...
This diff is collapsed.
Click to expand it.
src/metabase/automagic_dashboards/filters.clj
+
20
−
9
View file @
1f6a9022
...
...
@@ -50,16 +50,10 @@
identity
)
(
filter
field-reference?
)))
(
def
^
{
:arglists
'
([
field
])}
periodic-datetime?
"Is `field` a periodic datetime (eg. day of month)?"
(
comp
#
{
:minute-of-hour
:hour-of-day
:day-of-week
:day-of-month
:day-of-year
:week-of-year
:month-of-year
:quarter-of-year
}
:unit
))
(
defn
datetime?
"Is `field` a datetime?"
[
field
]
(
and
(
not
(
periodic-datetime?
field
))
(
and
(
not
(
(
disj
metabase.util.date/date-extract-units
:year
)
(
:unit
field
))
)
(
or
(
isa?
(
:base_type
field
)
:type/DateTime
)
(
field/unix-timestamp?
field
))))
...
...
@@ -75,6 +69,23 @@
(
isa?
special_type
:type/CreationTimestamp
)
inc
(
#
{
:type/State
:type/Country
}
special_type
)
inc
))
(
defn-
interleave-all
[
&
colls
]
(
lazy-seq
(
when-not
(
empty?
colls
)
(
concat
(
map
first
colls
)
(
apply
interleave-all
(
keep
(
comp
seq
rest
)
colls
))))))
(
defn-
sort-by-interestingness
[
fields
]
(
->>
fields
(
map
#
(
assoc
%
:interestingness
(
interestingness
%
)))
(
sort-by
interestingness
>
)
(
partition-by
:interestingness
)
(
mapcat
(
fn
[
fields
]
(
->>
fields
(
group-by
(
juxt
:base_type
:special_type
))
vals
(
apply
interleave-all
))))))
(
defn
interesting-fields
"Pick out interesting fields and sort them by interestingness."
...
...
@@ -83,7 +94,7 @@
(
filter
(
fn
[{
:keys
[
special_type
]
:as
field
}]
(
or
(
datetime?
field
)
(
isa?
special_type
:type/Category
))))
(
sort-by
interestingness
>
)
))
sort-by
-
interestingness
))
(
defn-
candidates-for-filtering
[
fieldset
cards
]
...
...
@@ -160,7 +171,7 @@
field/with-targets
)]
(
->>
dimensions
remove-unqualified
(
sort-by
interestingness
>
)
sort-by
-
interestingness
(
take
max-filters
)
(
reduce
(
fn
[
dashboard
candidate
]
...
...
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