Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter out dimension names that do not have dimension values #3726

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions runtime/queries/metricsview.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,19 +551,25 @@ func convertFilterToExpression(filter *runtimev1.MetricsViewFilter) *runtimev1.E
if len(filter.Include) > 0 {
var includeExprs []*runtimev1.Expression
for _, cond := range filter.Include {
domExpr := convertDimensionFilterToExpression(cond, false)
if domExpr != nil {
includeExprs = append(includeExprs, domExpr)
if len(cond.In) > 0 {
domExpr := convertDimensionFilterToExpression(cond, false)
if domExpr != nil {
includeExprs = append(includeExprs, domExpr)
}
}
}
exprs = append(exprs, expressionpb.Or(includeExprs))
if len(includeExprs) > 0 {
exprs = append(exprs, expressionpb.Or(includeExprs))
}
}

if len(filter.Exclude) > 0 {
for _, cond := range filter.Exclude {
domExpr := convertDimensionFilterToExpression(cond, true)
if domExpr != nil {
exprs = append(exprs, domExpr)
if len(cond.In) > 0 {
domExpr := convertDimensionFilterToExpression(cond, true)
if domExpr != nil {
exprs = append(exprs, domExpr)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@
],
timeStart: $timeControlsStore.timeStart,
timeEnd,
filter: $dashboardStore?.filters,
filter: {
exclude: $dashboardStore.filters.exclude?.filter((f) => f.in?.length),
include: $dashboardStore.filters.include?.filter((f) => f.in?.length),
},
},
{
query: {
Expand Down
12 changes: 10 additions & 2 deletions web-common/src/features/dashboards/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,22 @@ export const getFiltersForOtherDimensions = (
const filter: V1MetricsViewFilter = {
include:
filters.include
?.filter((dimensionValues) => dimensionName !== dimensionValues.name)
?.filter((dimensionValues) => {
return (
dimensionName !== dimensionValues.name && dimensionValues.in?.length
);
})
.map((dimensionValues) => ({
name: dimensionValues.name,
in: dimensionValues.in,
})) ?? [],
exclude:
filters.exclude
?.filter((dimensionValues) => dimensionName !== dimensionValues.name)
?.filter((dimensionValues) => {
return (
dimensionName !== dimensionValues.name && dimensionValues.in?.length
);
})
.map((dimensionValues) => ({
name: dimensionValues.name,
in: dimensionValues.in,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ function createMetricsViewTimeSeries(
metricViewName,
{
measureNames: measures,
filter: dashboardStore?.filters,
filter: {
exclude: dashboardStore.filters.exclude?.filter(
(f) => f.in?.length
),
include: dashboardStore.filters.include?.filter(
(f) => f.in?.length
),
},
timeStart: isComparison
? timeControls.comparisonAdjustedStart
: timeControls.adjustedStart,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ export function createTotalsForMeasure(
metricsViewName,
{
measures: measures.map((measure) => ({ name: measure })),
filter: noFilter ? { include: [], exclude: [] } : dashboard?.filters,
filter: noFilter
? { include: [], exclude: [] }
: {
exclude: dashboard.filters.exclude?.filter((f) => f.in?.length),
include: dashboard.filters.include?.filter((f) => f.in?.length),
},
timeStart: isComparison
? timeControls?.comparisonTimeStart
: timeControls.timeStart,
Expand Down