Skip to content

Commit

Permalink
Renaming distinct to unique values all over
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcos Iglesias committed Apr 1, 2021
1 parent 4d4f15a commit d5281cc
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion amundsen_application/static/js/config/config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ type SortCriteriaConfig = {
* Stats configuration options
*/
type StatsConfig = {
distinctTypeName: string;
uniqueValueTypeName: string;
};

/**
Expand Down
7 changes: 4 additions & 3 deletions amundsen_application/static/js/config/config-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ export function getAnalyticsConfig(): AnalyticsConfig {
}

/**
* Returns the stat type name for the distinct stat type
* Returns the stat type name for the unique value stat type
* @returns string or undefined
*/
export function getDistinctStatTypeName(): string | undefined {
return AppConfig.resourceConfig[ResourceType.table].stats?.distinctTypeName;
export function getUniqueValueStatTypeName(): string | undefined {
return AppConfig.resourceConfig[ResourceType.table].stats
?.uniqueValueTypeName;
}

/*
Expand Down
8 changes: 4 additions & 4 deletions amundsen_application/static/js/config/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ describe('getAnalyticsConfig', () => {
});
});

describe('getDistinctStatTypeName', () => {
it('returns the distinct stat type key name', () => {
describe('getUniqueValueStatTypeName', () => {
it('returns the unique value stat type key name', () => {
const expectedValue = 'test';

AppConfig.resourceConfig[ResourceType.table].stats = {
distinctTypeName: expectedValue,
uniqueValueTypeName: expectedValue,
};

expect(ConfigUtils.getDistinctStatTypeName()).toBe(expectedValue);
expect(ConfigUtils.getUniqueValueStatTypeName()).toBe(expectedValue);
});
});

Expand Down
2 changes: 1 addition & 1 deletion amundsen_application/static/js/utils/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as NumberUtils from './numberUtils';
import * as StatUtils from './stats';

jest.mock('config/config-utils', () => ({
getDistinctStatTypeName: jest.fn(() => 'distinctValues'),
getUniqueValueStatTypeName: jest.fn(() => 'distinctValues'),
getNumberFormat: jest.fn(() => null),
}));

Expand Down
10 changes: 5 additions & 5 deletions amundsen_application/static/js/utils/stats.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { formatDate } from 'utils/dateUtils';

import { getDistinctStatTypeName } from 'config/config-utils';
import { getUniqueValueStatTypeName } from 'config/config-utils';

import { ColumnUniqueValues, TableColumnStats } from 'interfaces/index';

Expand All @@ -12,15 +12,15 @@ const parseRawUniqueValues = (uniqueValues: string) =>
JSON.parse(uniqueValues.split("'").join('"'));

/**
* Parses the stats' distinct values key into an array of
* Parses the stats' unique values key into an array of
* objects with value and count properties
* @param statsList
* @returns ColumnUniqueValues[]
*/
export const getUniqueValues = (
statsList: TableColumnStats[]
): ColumnUniqueValues[] | [] => {
const uniqueValuesKey = getDistinctStatTypeName();
const uniqueValuesKey = getUniqueValueStatTypeName();
if (!uniqueValuesKey) {
return [];
}
Expand All @@ -39,12 +39,12 @@ export const getUniqueValues = (
};

/**
* Removes any stat identified as a distinct value
* Removes any stat identified as a unique value
* @param statsList
* @returns TableColumnStats[]
*/
export const filterOutUniqueValues = (statsList: TableColumnStats[]) => {
const uniqueValuesKey = getDistinctStatTypeName();
const uniqueValuesKey = getUniqueValueStatTypeName();

return statsList.filter((item) => item.stat_type !== uniqueValuesKey);
};
Expand Down
2 changes: 1 addition & 1 deletion docs/application_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ To achieve this, you will need to modify your custom configuration (config-custo
[ResourceType.table]: {
//...
stats: {
distinctTypeName: "keyNameExample",
uniqueValueTypeName: "keyNameExample",
},
}
```
Expand Down

0 comments on commit d5281cc

Please sign in to comment.