github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/webapp/javascript/util/updateRequests.ts (about)

     1  // TODO: figure out the correct types
     2  
     3  export function buildRenderURL(
     4    state: {
     5      from: string;
     6      until: string;
     7      query: string;
     8      refreshToken?: string;
     9      maxNodes?: string | number;
    10      groupBy?: string;
    11      groupByValue?: string;
    12    },
    13    fromOverride?: string,
    14    untilOverride?: string
    15  ) {
    16    const params = new URLSearchParams();
    17    params.set('query', state.query);
    18    params.set('from', fromOverride || state.from);
    19    params.set('until', untilOverride || state.until);
    20    state.refreshToken && params.set('refreshToken', state.refreshToken);
    21    if (state.maxNodes && state.maxNodes !== '0') {
    22      params.set('max-nodes', String(state.maxNodes));
    23    }
    24    state.groupBy && params.set('groupBy', state.groupBy);
    25    state.groupByValue && params.set('groupByValue', state.groupByValue);
    26  
    27    return `/render?${params}`;
    28  }
    29  
    30  export function buildMergeURLWithQueryID(state: {
    31    queryID: string;
    32    refreshToken?: string;
    33    maxNodes?: string | number;
    34  }) {
    35    const params = new URLSearchParams();
    36    params.set('queryID', state.queryID);
    37    state.refreshToken && params.set('refreshToken', state.refreshToken);
    38    if (state.maxNodes && state.maxNodes !== '0') {
    39      params.set('max-nodes', String(state.maxNodes));
    40    }
    41  
    42    return `/merge?${params}`;
    43  }