export async function getHistory()

in frontend/src/common.js [95:130]


export async function getHistory(path, platform, suite) {
  // Backend needs path without trailing /
  if (path && path.endsWith("/")) {
    path = path.substring(0, path.length - 1);
  }

  const cacheKey = `${path}_${platform}_${suite}`;
  let data = cacheGet(historyCache, cacheKey);
  if (data) {
    return data;
  }

  let params = `path=${path}`;
  if (platform && platform !== "all") {
    params += `&platform=${platform}`;
  }
  if (suite && suite !== "all") {
    params += `&suite=${suite}`;
  }
  const response = await fetch(`${COVERAGE_BACKEND_HOST}/v2/history?${params}`);
  data = await response.json();

  cacheSet(historyCache, cacheKey, data);

  // Check data has coverage values
  // These values are missing when going above 2 levels right now
  const coverage = data.filter((point) => {
    return point.coverage !== null;
  });
  if (coverage.length === 0) {
    console.warn(`No history data for ${path}`);
    return null;
  }

  return data;
}