public static Result restWorkflowSummariesForUser(String username) {
    JsonArray workflowSummaryArray = new JsonArray();
    List<AppResult> results = null;
    if (username == null || username.isEmpty()) {
      results = getSchedulerApplications(MAX_APPLICATIONS_IN_WORKFLOW);
    } else {
      results = getSchedulerApplications(username, MAX_APPLICATIONS_IN_WORKFLOW);
    }

    Map<IdUrlPair, List<AppResult>> flowExecIdToJobsMap = ControllerUtil
        .limitHistoryResults(ControllerUtil.groupJobs(results, ControllerUtil.GroupBy.FLOW_EXECUTION_ID),
            results.size(), MAX_FLOW_LIMIT);

    List<IdUrlPair> keyList = new ArrayList<IdUrlPair>(flowExecIdToJobsMap.keySet());

    for (IdUrlPair flowExecPair : keyList) {

      List<AppResult> mrJobsList = Lists.reverse(flowExecIdToJobsMap.get(flowExecPair));

      Map<IdUrlPair, List<AppResult>> jobDefIdToJobsMap =
          ControllerUtil.groupJobs(mrJobsList, ControllerUtil.GroupBy.JOB_EXECUTION_ID);

      Map<Severity, Long> jobSeverityCount = new HashMap<Severity, Long>();
      long totalFlowMemoryUsed = 0;
      long totalFlowMemoryWasted = 0;
      long totalFlowDelay = 0;
      long totalFlowRuntime = 0;
      Severity flowSeverity = Severity.NONE;

      for (IdUrlPair jobDefPair : jobDefIdToJobsMap.keySet()) {

        Severity jobseverity = Severity.NONE;
        long totalJobMemoryUsed = 0;
        long totalJobMemoryWasted = 0;

        for (AppResult job : jobDefIdToJobsMap.get(jobDefPair)) {

          totalJobMemoryUsed += job.resourceUsed;
          totalJobMemoryWasted += job.resourceWasted;

          if (job.severity.getValue() > jobseverity.getValue()) {
            jobseverity = job.severity;
          }
        }

        if (jobSeverityCount.containsKey(jobseverity)) {
          jobSeverityCount.put(jobseverity, jobSeverityCount.get(jobseverity) + 1);
        } else {
          jobSeverityCount.put(jobseverity, 1L);
        }

        if (jobseverity.getValue() > flowSeverity.getValue()) {
          flowSeverity = jobseverity;
        }

        totalFlowMemoryUsed += totalJobMemoryUsed;
        totalFlowMemoryWasted += totalJobMemoryWasted;
      }

      totalFlowDelay = Utils.getTotalWaittime(flowExecIdToJobsMap.get(flowExecPair));
      totalFlowRuntime = Utils.getTotalRuntime(flowExecIdToJobsMap.get(flowExecPair));

      JsonArray jobSeverity = new JsonArray();
      List<Severity> keys = getSortedSeverityKeys(jobSeverityCount.keySet());
      for (Severity key : keys) {
        JsonObject severityObject = new JsonObject();
        severityObject.addProperty(JsonKeys.SEVERITY, key.getText());
        severityObject.addProperty(JsonKeys.COUNT, jobSeverityCount.get(key));
        jobSeverity.add(severityObject);
      }

      // Execution record
      JsonObject dataset = new JsonObject();
      dataset.addProperty(JsonKeys.ID, mrJobsList.get(0).flowExecId);
      dataset.addProperty(JsonKeys.USERNAME, mrJobsList.get(0).username);
      dataset.addProperty(JsonKeys.START_TIME, mrJobsList.get(0).startTime);
      dataset.addProperty(JsonKeys.FINISH_TIME, mrJobsList.get(mrJobsList.size() - 1).finishTime);
      dataset.addProperty(JsonKeys.RUNTIME, totalFlowRuntime);
      dataset.addProperty(JsonKeys.WAITTIME, totalFlowDelay);
      dataset.addProperty(JsonKeys.RESOURCE_USED, totalFlowMemoryUsed);
      dataset.addProperty(JsonKeys.RESOURCE_WASTED, totalFlowMemoryWasted);
      dataset.addProperty(JsonKeys.QUEUE, mrJobsList.get(0).queueName);
      dataset.addProperty(JsonKeys.SEVERITY, flowSeverity.getText());
      dataset.addProperty(JsonKeys.SCHEDULER, mrJobsList.get(0).scheduler);
      dataset.addProperty(JsonKeys.FLOW_EXEC_ID, mrJobsList.get(0).flowExecId);
      dataset.addProperty(JsonKeys.FLOW_DEF_ID, mrJobsList.get(0).flowDefId);
      dataset.add(JsonKeys.JOBS_SEVERITY, jobSeverity);
      workflowSummaryArray.add(dataset);
    }
    JsonArray sortedWorkflowSummaryArray = getSortedJsonArrayByFinishTime(workflowSummaryArray);
    JsonObject parent = new JsonObject();
    parent.add(JsonKeys.WORKFLOW_SUMMARIES, sortedWorkflowSummaryArray);
    return ok(new Gson().toJson(parent));
  }
This method returns the workflow-summaries json response
@param username The username for which workflow-summaries must be returned
@return The json response of the workflow-summaries for the given user
Response data:
<pre>
{
 "workflow-summaries": [
 {
   "id": "http://workflow-id",
     "username": "search",
     "starttime": 1468818098875,
     "finishtime": 1468819946683,
     "runtime": 1855532,
     "waittime": 365368,
     "resourceused": 3306438656,
     "resourcewasted": 516978829,
     "severity": "Severe",
     "jobsseverity": [
   {
     "severity": "Severe",
       "count": 26
   },
   {
     "severity": "Moderate",
       "count": 3
   },
   {
     "severity": "Low",
       "count": 1
   },
   {
     "severity": "None",
       "count": 16
   }
   ]
 }
 ]
}
</pre>
app/controllers/api/v1/Web.java