def _aggregate_nomad_jobs(aggregated_jobs):
    """Aggregates the job counts.

    This is accomplished by using the stats that each
    parameterized job has about its children jobs.

    `jobs` should be a response from the Nomad API's jobs endpoint.
    """
    nomad_running_jobs = {}
    nomad_pending_jobs = {}
    for (aggregate_key, group) in aggregated_jobs:
        pending_jobs_count = 0
        running_jobs_count = 0
        for job in group:
            if job["JobSummary"]["Children"]:  # this can be null
                pending_jobs_count += job["JobSummary"]["Children"]["Pending"]
                running_jobs_count += job["JobSummary"]["Children"]["Running"]

        nomad_pending_jobs[aggregate_key] = pending_jobs_count
        nomad_running_jobs[aggregate_key] = running_jobs_count

    return nomad_pending_jobs, nomad_running_jobs