export function getBasicInfo()

in dashboard/new-dashboard/src/components/common/sideBar/InfoSidebarPerformance.ts [113:220]


export function getBasicInfo(params: CallbackDataParams, valueUnit: ValueUnit) {
  const seriesName = params.seriesName as string
  const dataSeries = params.value as OptionDataValue[]
  const dateMs = dataSeries[0] as number
  let projectName: string = params.seriesName as string
  let machineName: string | undefined
  let metricName: string | undefined
  let installerId: number | undefined
  let type: ValueUnit | undefined = valueUnit
  let branch: string | undefined
  let mode: string | undefined
  const dbType = dbTypeStore().dbType
  if (dbType == DBType.FLEET_PERF) {
    metricName = dataSeries[2] as string
    if (dataSeries[3] == "c") {
      type = "counter"
    }
    machineName = dataSeries[4] as string
    projectName = dataSeries[6] as string
    branch = dataSeries[7] as string
  }
  if (dbType == DBType.INTELLIJ_DEV || dbType == DBType.PERF_UNIT_TESTS || dbType == DBType.DIOGEN || dbType == DBType.QODANA || dbType == DBType.TOOLBOX) {
    metricName = dataSeries[2] as string
    if (dataSeries[3] == "c") {
      type = "counter"
    }
    machineName = dataSeries[4] as string
    projectName = dataSeries[6] as string
    branch = dataSeries[7] as string
    if (dbType == DBType.INTELLIJ_DEV) {
      mode = dataSeries[8] as string
    }
  }
  if (dbType == DBType.FLEET || dbType == DBType.STARTUP_TESTS) {
    metricName = dataSeries[2] as string
    if (!isDurationFormatterApplicable(metricName)) {
      type = "counter"
    }
    machineName = dataSeries[3] as string
    projectName = dataSeries[5] as string
    installerId = dataSeries[6] as number
    branch = dataSeries[10] as string
  }
  if (dbType == DBType.STARTUP_TESTS_DEV) {
    metricName = dataSeries[2] as string
    if (!isDurationFormatterApplicable(metricName)) {
      type = "counter"
    }
    machineName = dataSeries[3] as string
    projectName = dataSeries[5] as string
    branch = dataSeries[6] as string
  }
  if (dbType == DBType.JBR) {
    metricName = dataSeries[2] as string
    if (dataSeries[3] == "c") {
      type = "counter"
    }
    machineName = dataSeries[4] as string
    projectName = dataSeries[6] as string
    branch = dataSeries[8] as string
  }
  if (dbType == DBType.INTELLIJ) {
    metricName = dataSeries[2] as string
    if (dataSeries[3] == "c") {
      type = "counter"
    }
    machineName = dataSeries[4] as string
    projectName = dataSeries[6] as string
    installerId = dataSeries[7] as number
    branch = dataSeries[11] as string
    mode = dataSeries[12] as string
  }
  if (dbType == DBType.BAZEL) {
    metricName = dataSeries[2] as string
    if (dataSeries[3] == "c") {
      type = "counter"
    }
    machineName = dataSeries[4] as string
    projectName = dataSeries[6] as string
    branch = dataSeries[7] as string
  }
  if (dbType == DBType.UNKNOWN) {
    console.error("Unknown type of DB")
  }

  const buildId: number | undefined = getBuildId(params.value as (string | number)[])
  const changesUrl = installerId == undefined ? `${buildUrl(buildId as number)}&buildTab=changes` : `${buildUrl(installerId)}&buildTab=changes`
  const artifactsUrl = `${buildUrl(buildId as number)}&tab=artifacts`
  const installerUrl = installerId == undefined ? undefined : `${buildUrl(installerId)}&tab=artifacts`

  return {
    seriesName,
    build: getFullBuildId(params),
    artifactsUrl,
    changesUrl,
    installerUrl,
    date: timeFormatWithoutSeconds.format(dateMs),
    machineName: machineName as string,
    projectName,
    title: "Details",
    installerId,
    buildId: buildId as number,
    branch,
    metricName,
    type,
    mode,
  }
}