# All files / src/model tasks.coffee

100% Statements 6/6
100% Branches 0/0
100% Functions 0/0
100% Lines 6/6

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    361x
    1x
    1x
    1x

    1x

    1x
     mongoose = require "mongoose"
    server = require "../server"
    connectionDefault = server.connectionDefault
    Schema = mongoose.Schema

    TaskSchema = new Schema
      "status":
        type:      String
        required:  true
        enum:      ["Queued", "Processing", "Paused", "Cancelled", "Completed"]
        default:   "Queued"
        index:     true
      "transactions": [
        tid:        type: String, required: true
        tstatus:
          type:     String
          required: true
          enum:     ["Queued", "Processing", "Completed", "Failed"]
          default:  "Queued"
        error:        String
        rerunID:      String
        rerunStatus:  String
      ]
      "created":                type: Date, required: true, default: Date.now, index: true
      "completedDate":          Date
      "user":                   type: String, required: true
      "remainingTransactions":  type: Number, required: true
      "totalTransactions":      type: Number, required: true
      "batchSize":              type: Number, default: 1

    ###
    # The task object that describes a specific task within the OpenHIM.
    # It provides some metadata describing a task and contains a number of transaction IDs.
    ###
    exports.Task = connectionDefault.model 'Task', TaskSchema