Skip to content
Snippets Groups Projects
Commit 164f67a5 authored by Atte Keinänen's avatar Atte Keinänen
Browse files

Fix Lint and Flow errors, loosen summarize field criteria

parent 2c1c4bf2
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,11 @@ import React from "react";
import StructuredQuery from "metabase-lib/lib/queries/StructuredQuery";
import { getFieldRefFromColumn } from "metabase/qb/lib/actions";
import { isNumeric, isDate, getAggregator, isCompatibleAggregatorForField } from "metabase/lib/schema_metadata";
import {
isDate,
getAggregator,
isCompatibleAggregatorForField
} from "metabase/lib/schema_metadata";
import { capitalize } from "metabase/lib/formatting";
import type {
......@@ -20,11 +24,7 @@ export default ({ question, clicked }: ClickActionProps): ClickAction[] => {
const dateField = query.table().fields.filter(isDate)[0];
if (
!dateField ||
!clicked ||
!clicked.column ||
clicked.value !== undefined ||
!isNumeric(clicked.column)
!dateField || !clicked || !clicked.column || clicked.value !== undefined
) {
return [];
}
......@@ -32,7 +32,8 @@ export default ({ question, clicked }: ClickActionProps): ClickAction[] => {
return ["sum", "count"]
.map(getAggregator)
.filter((aggregator) => isCompatibleAggregatorForField(aggregator, column))
.filter(aggregator =>
isCompatibleAggregatorForField(aggregator, column))
.map(aggregator => ({
name: "summarize-by-time",
section: "sum",
......
/* @flow */
import { getFieldRefFromColumn } from "metabase/qb/lib/actions";
import { getAggregator, isCompatibleAggregatorForField, isNumeric, isSummable } from "metabase/lib/schema_metadata";
import {
getAggregator,
isCompatibleAggregatorForField
} from "metabase/lib/schema_metadata";
import type {
ClickAction,
......@@ -37,24 +40,31 @@ export default ({ question, clicked }: ClickActionProps): ClickAction[] => {
!clicked.column ||
clicked.value !== undefined ||
clicked.column.source !== "fields"
) {
// TODO Atte Keinänen 7/21/17: Does it slow down the drill-through option calculations remarkably
// that I removed the `isSummable` condition from here and use `isCompatibleAggregator` method below instead?
) {
return [];
}
const { column } = clicked;
// $FlowFixMe
return Object.entries(AGGREGATIONS)
.map(([aggregationShort, action]) => [getAggregator(aggregationShort), action])
.filter(([aggregator]) => isCompatibleAggregatorForField(aggregator, column))
.map(([aggregator, action]: [string, {
.map(([aggregationShort, action]) => [
getAggregator(aggregationShort),
action
])
.filter(([aggregator]) =>
isCompatibleAggregatorForField(aggregator, column))
// $FlowFixMe
.map(([aggregator, action]: [any, {
section: string,
title: string
}]) => ({
name: action.title.toLowerCase(),
...action,
question: () =>
question.summarize([aggregator.short, getFieldRefFromColumn(column)])
question.summarize([
aggregator.short,
getFieldRefFromColumn(column)
])
}));
};
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