Skip to content

Commit

Permalink
For duplicates, search in series list without initial series. (#642)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianmroz authored Jun 20, 2020
1 parent eb9d532 commit 7f7a0d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/client/components/series-menu/arithmetic-series-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export const ArithmeticSeriesMenu: React.SFC<ArithmeticOperationSeriesMenuProps>
onSeriesChange(series.setIn(["expression", "reference"], name));
}

const duplicate = !series.equals(initialSeries) && seriesList.getSeriesWithKey(series.key());
const otherSeries = seriesList.removeSeries(initialSeries);
const duplicate = otherSeries.getSeriesWithKey(series.key());
const expression = series.expression as ArithmeticExpression;
const operation = OPERATIONS.find(op => op.id === expression.operation);
const operand = measures.getMeasureByName(expression.reference);
Expand Down
4 changes: 3 additions & 1 deletion src/client/components/series-menu/quantile-series-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ const percentiles: Array<Preset<number>> = [

export const QuantileSeriesMenu: React.SFC<QuantileSeriesMenuProps> = ({ seriesList, initialSeries, measure, series, onChange }) => {

const otherSeries = seriesList.removeSeries(initialSeries);

function validateSeries(series: QuantileSeries): string | null {
if (series.percentile <= 0 || series.percentile >= 100) {
return "Percentile must be a number greater than 0 and lower than 100";
}
if (!series.equals(initialSeries) && seriesList.hasSeries(series)) {
if (otherSeries.hasSeriesWithKey(series.key())) {
return "This percentile is already define for this measure";
}
return null;
Expand Down

0 comments on commit 7f7a0d5

Please sign in to comment.