function refreshAccounting()

in frontend/src/old-pages/Clusters/Accounting.tsx [58:111]


function refreshAccounting(args: any, callback: any, list: any) {
  const startTime = getState(['app', 'clusters', 'accounting', 'startTime'])
  const endTime = getState(['app', 'clusters', 'accounting', 'endTime'])
  const queue = getState(['app', 'clusters', 'accounting', 'queue'])
  const nodes = getState(['app', 'clusters', 'accounting', 'nodes'])
  const clusterUser = getState(['app', 'clusters', 'accounting', 'user'])
  const jobName = getState(['app', 'clusters', 'accounting', 'jobName'])
  const jobState = getState(['app', 'clusters', 'accounting', 'jobState'])

  const clusterName = getState(['app', 'clusters', 'selected'])
  const defaultArgs = !args || Object.keys(args).length === 0 ? {} : args

  if (startTime && startTime !== '') defaultArgs['starttime'] = startTime

  if (endTime && endTime !== '') defaultArgs['endtime'] = endTime

  if (queue) defaultArgs['partition'] = queue

  if (nodes && nodes !== '') defaultArgs['nodelist'] = nodes

  if (jobName && jobName !== '') defaultArgs['name'] = jobName

  if (clusterUser && clusterUser !== '') defaultArgs['user'] = clusterUser

  if (jobState && jobState !== '') defaultArgs['state'] = jobState

  if (list) clearState(['clusters', 'index', clusterName, 'accounting', 'jobs'])

  setState(['app', 'clusters', 'accounting', 'pending'], true)
  const defaultCallback = (data: any) => {
    if (list) setState(['clusters', 'index', clusterName, 'accounting'], data)
    else callback && callback(data)
    clearState(['app', 'clusters', 'accounting', 'pending'])
  }
  const failCallback = (data: any) => {
    console.log('fail: ', data)
    clearState(['app', 'clusters', 'accounting', 'pending'])
  }
  if (clusterName) {
    const clusterPath = ['clusters', 'index', clusterName]
    const cluster = getState(clusterPath)
    let user = clusterDefaultUser(cluster)
    const headNode = getState([...clusterPath, 'headNode'])
    headNode &&
      SlurmAccounting(
        clusterName,
        headNode.instanceId,
        user,
        defaultArgs,
        defaultCallback,
        failCallback,
      )
  }
}