Skip to content

Commit 85bcd86

Browse files
github-actions[bot]Kishore Kumaar Natarajan
and
Kishore Kumaar Natarajan
committed
[Bug Fix] Window size changing unexpectedly (#178)
Signed-off-by: Kishore Kumaar Natarajan <[email protected]> Co-authored-by: Kishore Kumaar Natarajan <[email protected]> (cherry picked from commit da66ed6) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent eef17f9 commit 85bcd86

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

public/pages/TopNQueries/TopNQueries.tsx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -313,18 +313,26 @@ const TopNQueries = ({
313313
deleteAfterDays: newDeleteAfterDays,
314314
exporterType: newExporterType,
315315
});
316-
await core.http.put('/api/update_settings', {
317-
query: {
318-
metric,
319-
enabled,
320-
top_n_size: newTopN,
321-
window_size: `${newWindowSize}${newTimeUnit === 'MINUTES' ? 'm' : 'h'}`,
322-
exporterType: newExporterType,
323-
group_by: newGroupBy,
324-
delete_after_days: newDeleteAfterDays,
325-
dataSourceId: getDataSourceFromUrl().id, // TODO: get this dynamically from the URL
326-
},
327-
});
316+
const queryParams: Record<string, any> = {
317+
metric,
318+
enabled,
319+
top_n_size: newTopN,
320+
exporterType: newExporterType,
321+
group_by: newGroupBy,
322+
delete_after_days: newDeleteAfterDays,
323+
dataSourceId: getDataSourceFromUrl().id,
324+
};
325+
if (newTimeUnit === 'MINUTES') {
326+
newTimeUnit = 'm';
327+
}
328+
if (newTimeUnit === 'HOURS') {
329+
newTimeUnit = 'h';
330+
}
331+
if (newWindowSize && newTimeUnit) {
332+
queryParams.window_size = `${newWindowSize}${newTimeUnit}`;
333+
}
334+
335+
await core.http.put('/api/update_settings', { query: queryParams });
328336
} catch (error) {
329337
console.error('Failed to set settings:', error);
330338
}

0 commit comments

Comments
 (0)