async getWorkflowNodesAndTitle_()

in marketing-analytics/activation/data-tasks-coordinator/src/sentinel.js [554:594]


  async getWorkflowNodesAndTitle_(taskLogId, taskConfigId, lastRun) {
    let nodes, title, targetLogId;
    if (taskLogId) {
      const taskLog = await this.taskLogDao.load(taskLogId);
      if (!taskLog) {
        title = `Error_Not_found_TaskLogId ${taskLogId}`;
      } else {
        const startTime = taskLog.createTime.toDate();
        title = `${taskLog.taskId}' execution ${taskLogId},`
          + ` started at ${startTime.toUTCString()}`;
        targetLogId = taskLogId;
      }
    } else if (taskConfigId) {
      if (lastRun) {// get the last run task log id of the given task config
        const taskLog = await this.getLastRunTaskLog_(taskConfigId);
        if (!taskLog) {// Not run yet.
          title = `No ${taskConfigId}'s logs found. Show the workflow instead`;
        } else {
          targetLogId = taskLog.id;
          const startTime = taskLog.entity.createTime.toDate();
          title = `${taskConfigId}' latest execution,`
            + ` started at ${startTime.toUTCString()}`;
        }
      } else {
        title = `${taskConfigId} workflow`;
      }
    }
    if (targetLogId) {
      const logNodeLoader =
        new TaskLogNodeLoader(this.taskLogDao, this.taskConfigDao);
      nodes = await logNodeLoader.getWorkFlow(targetLogId);
    } else if (taskConfigId) {
      const configNodeLoader = new TaskConfigNodeLoader(this.taskConfigDao);
      nodes = await configNodeLoader.getWorkFlow(taskConfigId);
    } else {
      if (!title) {
        title = `Error_No_TaskLog_or_TaskConfig`;
      }
    }
    return { nodes, title };
  }