fix: revisit doesExceedThreshold logic (#423)

<img width="316" alt="Screenshot 2024-06-01 at 3 45 42 PM" src="https://github.com/hyperdxio/hyperdx/assets/5959690/46badb82-eb3a-419b-a50a-f0b0acc5b417">

<img width="449" alt="Screenshot 2024-06-01 at 3 45 34 PM" src="https://github.com/hyperdxio/hyperdx/assets/5959690/41633796-8916-4fe6-ab37-6892e3f25436">
This commit is contained in:
Warren 2024-06-01 15:49:05 -07:00 committed by GitHub
parent 5e17d3bd08
commit da866be776
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 14 additions and 10 deletions

View file

@ -0,0 +1,6 @@
---
'@hyperdx/api': patch
'@hyperdx/app': patch
---
fix: revisit doesExceedThreshold logic

View file

@ -84,11 +84,9 @@ describe('checkAlerts', () => {
it('doesExceedThreshold', () => {
expect(doesExceedThreshold(true, 10, 11)).toBe(true);
expect(doesExceedThreshold(true, 10, 10)).toBe(false);
expect(doesExceedThreshold(true, 10, 9)).toBe(false);
expect(doesExceedThreshold(false, 10, 11)).toBe(false);
expect(doesExceedThreshold(false, 10, 10)).toBe(false);
expect(doesExceedThreshold(true, 10, 10)).toBe(true);
expect(doesExceedThreshold(false, 10, 9)).toBe(true);
expect(doesExceedThreshold(false, 10, 10)).toBe(false);
});
it('expandToNestedObject', () => {

View file

@ -100,7 +100,7 @@ export const doesExceedThreshold = (
threshold: number,
value: number,
) => {
if (isThresholdTypeAbove && value > threshold) {
if (isThresholdTypeAbove && value >= threshold) {
return true;
} else if (!isThresholdTypeAbove && value < threshold) {
return true;

View file

@ -103,10 +103,10 @@ function AlertForm({
<div className="me-2 mb-2">
<Form.Select id="type" size="sm" {...register('type')}>
<option key="presence" value="presence">
more than
at least ()
</option>
<option key="absence" value="absence">
less than
less than ({'<'})
</option>
</Form.Select>
</div>

View file

@ -39,7 +39,7 @@ export default function EditChartFormAlerts({
id="type"
size="sm"
style={{
width: 140,
width: 170,
}}
value={alert?.type}
onChange={e => {
@ -51,10 +51,10 @@ export default function EditChartFormAlerts({
}}
>
<option key="presence" value="presence">
exceeds
is at least ()
</option>
<option key="absence" value="absence">
falls below
falls below ({'<'})
</option>
</Form.Select>
<div style={{ marginBottom: -20 }}>