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
3b40312e
Unverified
Commit
3b40312e
authored
2 years ago
by
Cam Saul
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove unused stuff in metabase-lib/queries/utils/description.js (#29192)
parent
53bae050
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/metabase-lib/queries/utils/description.js
+7
-84
7 additions, 84 deletions
frontend/src/metabase-lib/queries/utils/description.js
shared/src/metabase/mbql/util.cljc
+1
-1
1 addition, 1 deletion
shared/src/metabase/mbql/util.cljc
with
8 additions
and
85 deletions
frontend/src/metabase-lib/queries/utils/description.js
+
7
−
84
View file @
3b40312e
...
...
@@ -6,7 +6,6 @@ import inflection from "inflection";
import
{
stripId
}
from
"
metabase/lib/formatting
"
;
import
*
as
FIELD_REF
from
"
./field-ref
"
;
import
{
FilterClause
,
MetricClause
}
from
"
./description.styled.tsx
"
;
// NOTE: This doesn't support every MBQL clause, e.x. joins. It should also be moved to StructuredQuery.
...
...
@@ -22,13 +21,16 @@ export function formatField(fieldDef, options = {}) {
// metadata available, and the server side will generate a data structure
// containing all the applicable data for formatting a user-friendly description
// of a query.
//
// TODO: This is almost 100% duplicated with code in Question.ts, find a way to
// consolidate them
// -----------------------------------------------------------------------------
export
function
formatTableDescription
({
table
},
options
=
{})
{
function
formatTableDescription
({
table
},
options
=
{})
{
return
[
inflection
.
pluralize
(
table
)];
}
export
function
formatAggregationDescription
({
aggregation
},
options
=
{})
{
function
formatAggregationDescription
({
aggregation
},
options
=
{})
{
if
(
!
aggregation
||
!
aggregation
.
length
)
{
return
[];
}
...
...
@@ -80,21 +82,7 @@ export function formatAggregationDescription({ aggregation }, options = {}) {
);
}
export
function
formatBreakoutDescription
({
breakout
},
options
=
{})
{
if
(
!
breakout
||
!
breakout
.
length
)
{
return
[];
}
return
[
t
`Grouped by `
,
joinList
(
breakout
.
map
(
b
=>
b
),
"
and
"
,
),
];
}
export
function
formatFilterDescription
({
filter
},
options
=
{})
{
function
formatFilterDescription
({
filter
},
options
=
{})
{
if
(
!
filter
||
!
filter
.
length
)
{
return
[];
}
...
...
@@ -118,34 +106,6 @@ export function formatFilterDescription({ filter }, options = {}) {
];
}
export
function
formatOrderByDescription
(
parts
,
options
=
{})
{
const
orderBy
=
parts
[
"
order-by
"
];
if
(
!
orderBy
||
!
orderBy
.
length
)
{
return
[];
}
return
[
t
`Sorted by `
,
joinList
(
orderBy
.
map
(
field
=>
field
[
"
field
"
]
+
"
"
+
(
field
[
"
direction
"
]
===
"
asc
"
?
"
ascending
"
:
"
descending
"
),
),
"
and
"
,
),
];
}
export
function
formatLimitDescription
({
limit
},
options
=
{})
{
if
(
limit
==
null
)
{
return
[];
}
return
[
limit
,
"
"
,
inflection
.
inflect
(
"
row
"
,
limit
)];
}
export
function
formatQueryDescription
(
parts
,
options
=
{})
{
if
(
!
parts
)
{
return
""
;
...
...
@@ -153,24 +113,14 @@ export function formatQueryDescription(parts, options = {}) {
options
=
{
jsx
:
false
,
sections
:
[
"
table
"
,
"
aggregation
"
,
"
breakout
"
,
"
filter
"
,
"
order-by
"
,
"
limit
"
,
],
sections
:
[
"
table
"
,
"
aggregation
"
,
"
filter
"
],
...
options
,
};
const
sectionFns
=
{
table
:
formatTableDescription
,
aggregation
:
formatAggregationDescription
,
breakout
:
formatBreakoutDescription
,
filter
:
formatFilterDescription
,
"
order-by
"
:
formatOrderByDescription
,
limit
:
formatLimitDescription
,
};
// these array gymnastics are needed to support JSX formatting
...
...
@@ -188,33 +138,6 @@ export function formatQueryDescription(parts, options = {}) {
}
}
export
function
getDatetimeFieldUnit
(
field
)
{
if
(
field
&&
FIELD_REF
.
isLocalField
(
field
))
{
const
options
=
field
[
2
];
if
(
options
)
{
return
options
[
"
temporal-unit
"
];
}
}
return
null
;
}
export
function
getAggregationType
(
aggregation
)
{
return
aggregation
&&
aggregation
[
0
];
}
export
function
getAggregationField
(
aggregation
)
{
return
aggregation
&&
aggregation
[
1
];
}
export
function
getQueryColumn
(
tableMetadata
,
field
)
{
const
target
=
FIELD_REF
.
getFieldTarget
(
field
,
tableMetadata
);
const
column
=
{
...
target
.
field
};
if
(
FIELD_REF
.
isLocalField
(
field
)
&&
getDatetimeFieldUnit
(
field
))
{
column
.
unit
=
getDatetimeFieldUnit
(
field
);
}
return
column
;
}
export
function
joinList
(
list
,
joiner
)
{
return
_
.
flatten
(
list
.
map
((
l
,
i
)
=>
(
i
===
list
.
length
-
1
?
[
l
]
:
[
l
,
joiner
])),
...
...
This diff is collapsed.
Click to expand it.
shared/src/metabase/mbql/util.cljc
+
1
−
1
View file @
3b40312e
...
...
@@ -303,7 +303,7 @@
"Rewrite various 'syntatic sugar' filter clauses like `:time-interval` and `:inside` as simpler, logically
equivalent clauses. This can be used to simplify the number of filter clauses that need to be supported by anything
that needs to enumerate all the possible filter types (such as driver query processor implementations, or the
implementation
`
negate-filter-clause
`
below.)"
implementation
[[
negate-filter-clause
]]
below.)"
[
filter-clause
:-
mbql.s/Filter
]
(
->
filter-clause
desugar-current-relative-datetime
...
...
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