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

Remove "ANY" as a query quality option #347

Merged
merged 1 commit into from
Aug 14, 2024
Merged
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
10 changes: 7 additions & 3 deletions pkg/sitewise/api/property_aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ func aggregateQueryToInput(query models.AssetPropertyValueQuery) *iotsitewise.Ge
timeOrdering = aws.String("ASCENDING")
)

if query.Quality != "" && query.Quality != "ANY" {
qualities = aws.StringSlice([]string{query.Quality})
quality := query.Quality

if quality == "" || quality == "ANY" {
qualities = aws.StringSlice([]string{"GOOD"})
} else {
qualities = aws.StringSlice([]string{quality})
}

from, to := util.TimeRangeToUnix(query.TimeRange)
Expand Down Expand Up @@ -84,4 +88,4 @@ func GetAssetPropertyAggregates(ctx context.Context, client client.SitewiseClien
NextToken: resp.NextToken,
},
}, nil
}
}
8 changes: 6 additions & 2 deletions pkg/sitewise/api/property_aggregate_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ func aggregateBatchQueryToInput(query models.AssetPropertyValueQuery) *iotsitewi
timeOrdering = aws.String("ASCENDING")
)

if query.Quality != "" && query.Quality != "ANY" {
qualities = aws.StringSlice([]string{query.Quality})
quality := query.Quality

if quality == "" || quality == "ANY" {
qualities = aws.StringSlice([]string{"GOOD"})
} else {
qualities = aws.StringSlice([]string{quality})
}

from, to := util.TimeRangeToUnix(query.TimeRange)
Expand Down
10 changes: 7 additions & 3 deletions pkg/sitewise/api/property_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ func historyQueryToInput(query models.AssetPropertyValueQuery) *iotsitewise.GetA
qualities []*string
)

if query.Quality != "" && query.Quality != "ANY" {
qualities = aws.StringSlice([]string{query.Quality})
quality := query.Quality

if quality == "" || quality == "ANY" {
qualities = aws.StringSlice([]string{"GOOD"})
} else {
qualities = aws.StringSlice([]string{quality})
}

from, to := util.TimeRangeToUnix(query.TimeRange)
Expand Down Expand Up @@ -66,4 +70,4 @@ func GetAssetPropertyValues(ctx context.Context, client client.SitewiseClient,
Query: modifiedQuery,
},
nil
}
}
8 changes: 6 additions & 2 deletions pkg/sitewise/api/property_history_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ func historyBatchQueryToInput(query models.AssetPropertyValueQuery) *iotsitewise
qualities []*string
)

if query.Quality != "" && query.Quality != "ANY" {
qualities = aws.StringSlice([]string{query.Quality})
quality := query.Quality

if quality == "" || quality == "ANY" {
qualities = aws.StringSlice([]string{"GOOD"})
} else {
qualities = aws.StringSlice([]string{quality})
}

from, to := util.TimeRangeToUnix(query.TimeRange)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sitewise/api/property_interpolated.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func interpolatedQueryToInputs(query models.AssetPropertyValueQuery) []*iotsitew
endTimeInSeconds := to.Unix()

quality := query.Quality
if quality == "" || query.Quality == "ANY" {
if quality == "" || quality == "ANY" {
quality = "GOOD"
}

Expand Down
9 changes: 2 additions & 7 deletions src/components/query/QualityAndOrderRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,11 @@ const interpolatedResolutions: Array<SelectableValue<SiteWiseResolution>> = [
];

const qualities: Array<SelectableValue<SiteWiseQuality>> = [
{ value: SiteWiseQuality.ANY, label: 'ANY' },
{ value: SiteWiseQuality.GOOD, label: 'GOOD' },
{ value: SiteWiseQuality.BAD, label: 'BAD' },
{ value: SiteWiseQuality.UNCERTAIN, label: 'UNCERTAIN' },
];

const interpolatedPropertyQualities: Array<SelectableValue<SiteWiseQuality>> = qualities.slice(1);

const ordering: Array<SelectableValue<SiteWiseTimeOrder>> = [
{ value: SiteWiseTimeOrder.ASCENDING, label: 'ASCENDING' },
{ value: SiteWiseTimeOrder.DESCENDING, label: 'DESCENDING' },
Expand Down Expand Up @@ -106,16 +103,14 @@ export class QualityAndOrderRow extends PureComponent<Props> {

render() {
const { query } = this.props;
const currQualities =
query.queryType === QueryType.PropertyInterpolated ? interpolatedPropertyQualities : qualities;
return (
<>
<EditorField label="Quality" width={15} htmlFor="quality">
<Select
id="quality"
aria-label="Quality"
options={currQualities}
value={currQualities.find((v) => v.value === query.quality) ?? currQualities[0]}
options={qualities}
value={qualities.find((v) => v.value === query.quality) ?? qualities[0]}
onChange={this.onQualityChange}
isSearchable={true}
menuPlacement="auto"
Expand Down
12 changes: 9 additions & 3 deletions src/components/query/QueryEditor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ describe('QueryEditor', () => {
expect(screen.getByText('Expand Time Range')).toBeInTheDocument();
expect(screen.getByText('Time')).toBeInTheDocument();
expect(screen.getByText('Format')).toBeInTheDocument();
// GOOD as the quality default
expect(screen.getByText('GOOD')).toBeInTheDocument();
});
});

Expand All @@ -82,6 +84,8 @@ describe('QueryEditor', () => {
expect(screen.getByText('Quality')).toBeInTheDocument();
expect(screen.getByText('Time')).toBeInTheDocument();
expect(screen.getByText('Format')).toBeInTheDocument();
// GOOD as the quality default
expect(screen.getByText('GOOD')).toBeInTheDocument();
});
});

Expand All @@ -98,6 +102,8 @@ describe('QueryEditor', () => {
expect(screen.getByText('Quality')).toBeInTheDocument();
expect(screen.getByText('Format')).toBeInTheDocument();
expect(screen.getByText('Resolution')).toBeInTheDocument();
// GOOD as the quality default
expect(screen.getByText('GOOD')).toBeInTheDocument();
});
});

Expand All @@ -111,10 +117,8 @@ describe('QueryEditor', () => {
expect(screen.getByText('Quality')).toBeInTheDocument();
expect(screen.getByText('Resolution')).toBeInTheDocument();
expect(screen.getByText('Format')).toBeInTheDocument();

// Interpolated Property queries should not have ANY as the quality default
// GOOD as the quality default
expect(screen.getByText('GOOD')).toBeInTheDocument();
expect(screen.queryByText('ANY')).not.toBeInTheDocument();
});
});

Expand All @@ -134,6 +138,8 @@ describe('QueryEditor', () => {
expect(screen.getByText('Client cache')).toBeInTheDocument();
expect(screen.getByText('Time')).toBeInTheDocument();
expect(screen.getByText('Format')).toBeInTheDocument();
// GOOD as the quality default
expect(screen.getByText('GOOD')).toBeInTheDocument();
});
});

Expand Down
Loading