-
Notifications
You must be signed in to change notification settings - Fork 42
OU-1040: feat/absolute start dates #749
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
base: main
Are you sure you want to change the base?
Changes from all commits
898ae22
ba22dfb
97d076a
6497191
d857007
b8f4ed7
0c54136
9923c13
a5864d2
04c8326
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 |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ import { | |
| onIncidentFiltersSelect, | ||
| parseUrlParams, | ||
| updateBrowserUrl, | ||
| DAY_MS, | ||
| } from './utils'; | ||
| import { groupAlertsForTable, convertToAlerts } from './processAlerts'; | ||
| import { CompressArrowsAltIcon, CompressIcon, FilterIcon } from '@patternfly/react-icons'; | ||
|
|
@@ -229,49 +230,57 @@ const IncidentsPage = () => { | |
| }, [incidentsActiveFilters.days]); | ||
|
|
||
| useEffect(() => { | ||
| (async () => { | ||
| const currentTime = incidentsLastRefreshTime; | ||
| Promise.all( | ||
| timeRanges.map(async (range) => { | ||
| const response = await fetchDataForIncidentsAndAlerts( | ||
| safeFetch, | ||
| range, | ||
| createAlertsQuery(incidentForAlertProcessing), | ||
| ); | ||
| return response.data.result; | ||
| }), | ||
| ) | ||
| .then((results) => { | ||
| const prometheusResults = results.flat(); | ||
| const alerts = convertToAlerts( | ||
| prometheusResults, | ||
| incidentForAlertProcessing, | ||
| currentTime, | ||
| ); | ||
| // Guard: don't process if no incidents selected or timeRanges not ready | ||
| if (incidentForAlertProcessing.length === 0 || timeRanges.length === 0) { | ||
| return; | ||
| } | ||
|
|
||
| const currentTime = incidentsLastRefreshTime; | ||
|
|
||
| // Always fetch 15 days of alert data so firstTimestamp is computed from full history | ||
| const fetchTimeRanges = getIncidentsTimeRanges(15 * DAY_MS, currentTime); | ||
|
|
||
| Promise.all( | ||
| fetchTimeRanges.map(async (range) => { | ||
| const response = await fetchDataForIncidentsAndAlerts( | ||
| safeFetch, | ||
| range, | ||
| createAlertsQuery(incidentForAlertProcessing), | ||
| ); | ||
| return response.data.result; | ||
| }), | ||
| ) | ||
| .then((alertsResults) => { | ||
| const prometheusResults = alertsResults.flat(); | ||
| const alerts = convertToAlerts( | ||
| prometheusResults, | ||
| incidentForAlertProcessing, | ||
| currentTime, | ||
| daysSpan, | ||
| ); | ||
| dispatch( | ||
| setAlertsData({ | ||
| alertsData: alerts, | ||
| }), | ||
| ); | ||
| if (rules && alerts) { | ||
| dispatch( | ||
| setAlertsData({ | ||
| alertsData: alerts, | ||
| setAlertsTableData({ | ||
| alertsTableData: groupAlertsForTable(alerts, rules), | ||
| }), | ||
| ); | ||
| if (rules && alerts) { | ||
| dispatch( | ||
| setAlertsTableData({ | ||
| alertsTableData: groupAlertsForTable(alerts, rules), | ||
| }), | ||
| ); | ||
| } | ||
| if (!isEmpty(filteredData)) { | ||
| dispatch(setAlertsAreLoading({ alertsAreLoading: false })); | ||
| } else { | ||
| dispatch(setAlertsAreLoading({ alertsAreLoading: true })); | ||
| } | ||
| }) | ||
| .catch((err) => { | ||
| // eslint-disable-next-line no-console | ||
| console.log(err); | ||
| }); | ||
| })(); | ||
| }, [incidentForAlertProcessing]); | ||
| } | ||
| if (!isEmpty(filteredData)) { | ||
| dispatch(setAlertsAreLoading({ alertsAreLoading: false })); | ||
| } else { | ||
| dispatch(setAlertsAreLoading({ alertsAreLoading: true })); | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }) | ||
| .catch((err) => { | ||
| // eslint-disable-next-line no-console | ||
| console.error(err); | ||
| }); | ||
| }, [incidentForAlertProcessing, timeRanges, rules]); | ||
|
Comment on lines
232
to
+283
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.
Line 259 passes Proposed fix- }, [incidentForAlertProcessing, timeRanges, rules]);
+ }, [incidentForAlertProcessing, timeRanges, rules, daysSpan]);🤖 Prompt for AI Agents |
||
|
|
||
| useEffect(() => { | ||
| if (!isInitialized) return; | ||
|
|
@@ -287,30 +296,34 @@ const IncidentsPage = () => { | |
| ? incidentsActiveFilters.days[0].split(' ')[0] + 'd' | ||
| : '', | ||
| ); | ||
| const calculatedTimeRanges = getIncidentsTimeRanges(daysDuration, currentTime); | ||
|
|
||
| const isGroupSelected = !!selectedGroupId; | ||
| const incidentsQuery = isGroupSelected | ||
| ? `cluster_health_components_map{group_id='${selectedGroupId}'}` | ||
| : 'cluster_health_components_map'; | ||
|
|
||
| // Always fetch 15 days of data so firstTimestamp is computed from full history | ||
| const fetchTimeRanges = getIncidentsTimeRanges(15 * DAY_MS, currentTime); | ||
|
|
||
| Promise.all( | ||
| calculatedTimeRanges.map(async (range) => { | ||
| fetchTimeRanges.map(async (range) => { | ||
| const response = await fetchDataForIncidentsAndAlerts(safeFetch, range, incidentsQuery); | ||
| return response.data.result; | ||
| }), | ||
| ) | ||
| .then((results) => { | ||
| const prometheusResults = results.flat(); | ||
| const incidents = convertToIncidents(prometheusResults, currentTime); | ||
| .then((incidentsResults) => { | ||
| const prometheusResults = incidentsResults.flat(); | ||
| const incidents = convertToIncidents(prometheusResults, currentTime, daysDuration); | ||
|
|
||
| // Update the raw, unfiltered incidents state | ||
| dispatch(setIncidents({ incidents })); | ||
|
|
||
| const filteredData = filterIncident(incidentsActiveFilters, incidents); | ||
|
|
||
| // Filter the incidents and dispatch | ||
| dispatch( | ||
| setFilteredIncidentsData({ | ||
| filteredIncidentsData: filterIncident(incidentsActiveFilters, incidents), | ||
| filteredIncidentsData: filteredData, | ||
| }), | ||
| ); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.