Skip to content

Commit

Permalink
addressing PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
xtinec committed Nov 29, 2018
1 parent c11e9c8 commit a4597af
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
4 changes: 2 additions & 2 deletions superset/assets/package.json
Expand Up @@ -15,8 +15,8 @@
"dev-server": "webpack-dev-server --mode=development --progress",
"prod": "node --max_old_space_size=4096 webpack --mode=production --colors --progress",
"build": "NODE_ENV=production webpack --mode=production --colors --progress",
"lint": "eslint --ignore-path=.eslintignore --ext .js,.jsx . && tslint -c tslint.json ./src/**/*.ts{,x}",
"lint-fix": "eslint --fix --ignore-path=.eslintignore --ext .js,.jsx . && tslint -c tslint.json --fix ./src/**/*.ts{,x}",
"lint": "eslint --ignore-path=.eslintignore --ext .js,.jsx . && tslint -c tslint.json ./{src,spec}/**/*.ts{,x}",
"lint-fix": "eslint --fix --ignore-path=.eslintignore --ext .js,.jsx . && tslint -c tslint.json --fix ./{src,spec}/**/*.ts{,x}",
"sync-backend": "babel-node --presets env src/syncBackend.js",
"cypress": "cypress",
"cypress-debug": "cypress open --config watchForFileChanges=true"
Expand Down
11 changes: 7 additions & 4 deletions superset/assets/spec/javascripts/superset-ui/Metric.test.ts
@@ -1,4 +1,7 @@
import { AdhocMetric, Aggregate, ExpressionType, Metrics } from 'src/query/Metric';
import { ColumnType } from 'src/query/Column';
import {
AdhocMetric, Aggregate, ExpressionType, LABEL_MAX_LENGTH, Metrics,
} from 'src/query/Metric';

describe('Metrics', () => {
let metrics: Metrics;
Expand All @@ -22,7 +25,7 @@ describe('Metrics', () => {
column: {
columnName: 'sum_girls',
id: 5,
type: 'BIGINT',
type: ColumnType.BIGINT,
},
expressionType: ExpressionType.SIMPLE,
};
Expand All @@ -35,7 +38,7 @@ describe('Metrics', () => {
column: {
columnName: 'sum_girls',
id: 5,
type: 'BIGINT',
type: ColumnType.BIGINT,
},
expressionType: 'SIMPLE',
label: 'AVG(sum_girls)',
Expand Down Expand Up @@ -87,6 +90,6 @@ describe('Metrics', () => {
...formData,
metric: adhocMetric,
});
expect(metrics.getLabels()).toEqual(['COUNT(verrrrrrrrry_loooooooooooooooooooo...']);
expect(metrics.getLabels()[0].length).toBeLessThanOrEqual(LABEL_MAX_LENGTH);
});
});
Expand Up @@ -8,7 +8,7 @@ describe('queryObjectBuilder', () => {
expect(query.granularity).toEqual('ds');
});

it('should build granularity for sql alchemy datasources', () => {
it('should build granularity for sql druid datasources', () => {
query = build({datasource: '5__druid', granularity: 'ds'});
expect(query.granularity).toEqual('ds');
});
Expand Down
20 changes: 19 additions & 1 deletion superset/assets/src/query/Column.ts
@@ -1,6 +1,24 @@
export enum ColumnType {
DOUBLE = 'DOUBLE',
FLOAT = 'FLOAT',
INT = 'INT',
BIGINT = 'BIGINT',
LONG = 'LONG',
REAL = 'REAL',
NUMERIC = 'NUMERIC',
DECIMAL = 'DECIMAL',
MONEY = 'MONEY',
DATE = 'DATE',
TIME = 'TIME',
DATETIME = 'DATETIME',
VARCHAR = 'VARCHAR',
STRING = 'STRING',
CHAR = 'CHAR',
}

// TODO: fill out additional fields of the Column interface
export default interface Column {
id: number;
type: string;
type: ColumnType;
columnName: string;
}
5 changes: 4 additions & 1 deletion superset/assets/src/query/Metric.ts
@@ -1,6 +1,8 @@
import Column from './Column';
import FormData from './FormData';

export const LABEL_MAX_LENGTH = 43;

export enum MetricKey {
METRIC = 'metric',
METRICS = 'metrics',
Expand Down Expand Up @@ -90,6 +92,7 @@ export class Metrics {
} else {
label = metric.sqlExpression;
}
return label.length < 43 ? label : `${label.substring(0, 40)}...`;
return label.length <= LABEL_MAX_LENGTH ? label :
`${label.substring(0, LABEL_MAX_LENGTH - 3)}...`;
}
}

0 comments on commit a4597af

Please sign in to comment.