diff --git a/static/app/views/explore/utils/setExploreAttributeBounds.spec.tsx b/static/app/views/explore/utils/setExploreAttributeBounds.spec.tsx index 6169a1a69f37..1adb70d8a4de 100644 --- a/static/app/views/explore/utils/setExploreAttributeBounds.spec.tsx +++ b/static/app/views/explore/utils/setExploreAttributeBounds.spec.tsx @@ -30,4 +30,10 @@ describe('setExploreAttributeBounds', () => { 'duration:>=1.5 duration:<9' ); }); + + it('writes tiny and huge bounds without exponent notation', () => { + expect(setExploreAttributeBounds('', 'value', 1e-7, 1e21)).toBe( + 'value:>=0.0000001 value:<1000000000000000000000' + ); + }); }); diff --git a/static/app/views/explore/utils/setExploreAttributeBounds.tsx b/static/app/views/explore/utils/setExploreAttributeBounds.tsx index 72633c4e55bc..1e938b9c452f 100644 --- a/static/app/views/explore/utils/setExploreAttributeBounds.tsx +++ b/static/app/views/explore/utils/setExploreAttributeBounds.tsx @@ -12,6 +12,18 @@ export function setExploreAttributeBounds( ): string { const search = new MutableSearch(query); // `shouldEscape` is off so the comparison operators (`>=`, `<`) aren't quoted. - search.setFilterValues(attribute, [`>=${min}`, `<${max}`], false); + search.setFilterValues( + attribute, + [`>=${formatSearchNumber(min)}`, `<${formatSearchNumber(max)}`], + false + ); return search.formatString(); } + +/** + * The search grammar has no exponent syntax, so `1e-7` must be written out as + * `0.0000001`. + */ +function formatSearchNumber(value: number): string { + return value.toLocaleString(undefined, {useGrouping: false, maximumFractionDigits: 20}); +}