github.com/hernad/nomad@v1.6.112/ui/mirage/serializers/job-version.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import ApplicationSerializer from './application';
     7  
     8  export default ApplicationSerializer.extend({
     9    serialize() {
    10      var json = ApplicationSerializer.prototype.serialize.apply(this, arguments);
    11  
    12      if (!(json instanceof Array)) {
    13        json = [json];
    14      }
    15  
    16      return json
    17        .sortBy('SubmitTime')
    18        .reverse()
    19        .reduce(
    20          (hash, version) => {
    21            hash.Diffs.push(version.Diff);
    22            delete version.Diff;
    23  
    24            // ID is used for record tracking within Mirage,
    25            // but Nomad uses the JobID as the version ID.
    26            version.ID = version.TempVersionID;
    27            hash.Versions.push(version);
    28            return hash;
    29          },
    30          { Versions: [], Diffs: [] }
    31        );
    32    },
    33  });