in scripts/dashboard-importer/src/dashboards/converter/template_variables/interval.ts [20:42]
function getIntervalMapping(tv: TemplateVariable): Result<[string, string]> {
if (tv.type !== 'interval') {
return warning([
`getIntervalMapping received type ${tv.type} instead of interval`,
]);
}
const name = tv.name;
const options = tv.options || [];
const tvCurrentValue =
typeof tv.current?.value === 'string' ? tv.current?.value : '';
const selectedValue =
options.filter((option) => option.selected)[0]?.value ||
tvCurrentValue ||
options[0]?.value;
if (selectedValue === undefined) {
return warning([`No suitable mapping found for template variable ${name}`]);
}
if (selectedValue.startsWith('$')) {
return success([name, '${__interval}']);
}
return success([name, selectedValue]);
}