-
Notifications
You must be signed in to change notification settings - Fork 18
swith direct index query to api call #312
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ import { Monitor } from '../../../server/models/types'; | |
import { get } from 'lodash'; | ||
|
||
const SEARCH_MONITORS = 'alerting/SEARCH_MONITORS'; | ||
const SEARCH_ALERTS = 'alerting/SEARCH_ALERTS'; | ||
|
||
export interface Monitors { | ||
requesting: boolean; | ||
|
@@ -84,6 +85,19 @@ const reducer = handleActions<Monitors>( | |
errorMessage: action.error, | ||
}), | ||
}, | ||
|
||
//TODO: add requesting and errorMessage | ||
[SEARCH_ALERTS]: { | ||
REQUEST: (state: Monitors): Monitors => ({ | ||
...state | ||
}), | ||
SUCCESS: (state: Monitors, action: APIResponseAction): Monitors => ({ | ||
...state | ||
}), | ||
FAILURE: (state: Monitors, action: APIResponseAction): Monitors => ({ | ||
...state | ||
}), | ||
}, | ||
Comment on lines
+90
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe don't need to store alert info in redux store, but can you at least update the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, not sure if this will impact other components using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, not a blocker. If anything, adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added toto here, if any client components using these search APIs needs |
||
}, | ||
initialDetectorsState | ||
); | ||
|
@@ -94,4 +108,16 @@ export const searchMonitors = (): APIAction => ({ | |
client.post(`..${ALERTING_NODE_API._SEARCH}`, {}), | ||
}); | ||
|
||
export const searchAlerts = (monitorId: string, startTime: number, endTime: number): APIAction => ({ | ||
type: SEARCH_ALERTS, | ||
request: (client: IHttpService) => | ||
client.get(`..${ALERTING_NODE_API.ALERTS}`,{ | ||
params: { | ||
monitorId: monitorId, | ||
startTime: startTime, | ||
endTime: endTime, | ||
}, | ||
}), | ||
}); | ||
|
||
export default reducer; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ import { AD_NODE_API } from '../../../utils/constants'; | |
import { AnomalyData } from '../../models/interfaces'; | ||
|
||
const DETECTOR_RESULTS = 'ad/DETECTOR_RESULTS'; | ||
const SEARCH_ANOMALY_RESULTS = 'ad/SEARCH_ANOMALY_RESULTS'; | ||
|
||
export interface Anomalies { | ||
requesting: boolean; | ||
|
@@ -60,6 +61,19 @@ const reducer = handleActions<Anomalies>( | |
errorMessage: action.error.data.error, | ||
}), | ||
}, | ||
|
||
//TODO: add requesting and errorMessage | ||
[SEARCH_ANOMALY_RESULTS]: { | ||
REQUEST: (state: Anomalies): Anomalies => ({ | ||
...state | ||
}), | ||
SUCCESS: (state: Anomalies, action: APIResponseAction): Anomalies => ({ | ||
...state | ||
}), | ||
FAILURE: (state: Anomalies): Anomalies => ({ | ||
...state | ||
}), | ||
}, | ||
Comment on lines
+66
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same thing here |
||
}, | ||
initialDetectorsState | ||
); | ||
|
@@ -75,4 +89,11 @@ export const getDetectorResults = ( | |
}), | ||
}); | ||
|
||
export const searchResults = (requestBody: any): APIAction => ({ | ||
type: SEARCH_ANOMALY_RESULTS, | ||
request: (client: IHttpService) => | ||
client.post(`..${AD_NODE_API.DETECTOR}/results/_search`, requestBody), | ||
}); | ||
|
||
|
||
export default reducer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: I see this was already like this before, but I feel that overall we should try to avoid making direct calls and using the results directly, since it may cause errors to use those results/responses in downstream functions, etc. This is where redux store can help here in storing data and error messages. Not a blocker obviously
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have to use direct calls because we are calling same API in multiple places of same component, but current redux store does not support. We have an issue #23 for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for clarifying. Another solution may be making reducer functions more fine-grained and/or storing more fine-grained results in the redux store. Will add suggestion to the issue.