Spaces:
Sleeping
Sleeping
| const mongoose = require('mongoose'); | |
| const queueJobSchema = new mongoose.Schema( | |
| { | |
| contractId: { | |
| type: mongoose.Schema.Types.ObjectId, | |
| ref: 'Contract', | |
| required: true, | |
| index: true, | |
| }, | |
| status: { | |
| type: String, | |
| enum: ['queued', 'processing', 'completed', 'failed'], | |
| default: 'queued', | |
| index: true, | |
| }, | |
| progress: { | |
| type: Number, | |
| default: 0, | |
| min: 0, | |
| max: 100, | |
| }, | |
| step: { | |
| type: String, | |
| default: 'Initializing analysis', | |
| }, | |
| error: { | |
| type: String, | |
| default: null, | |
| }, | |
| lockedAt: { | |
| type: Date, | |
| default: null, | |
| }, | |
| lockedBy: { | |
| type: String, // e.g. worker ID or process ID | |
| default: null, | |
| }, | |
| attempts: { | |
| type: Number, | |
| default: 0, | |
| }, | |
| }, | |
| { timestamps: true } | |
| ); | |
| module.exports = mongoose.model('QueueJob', queueJobSchema); | |