⏱️ Added a timestamp to job results schema
This commit is contained in:
@@ -3,7 +3,8 @@ const mongoose = require("mongoose");
|
||||
const JobResultScehma = mongoose.Schema({
|
||||
id: Number,
|
||||
status: String,
|
||||
failedReason: Object
|
||||
failedReason: Object,
|
||||
timestamp: Date,
|
||||
});
|
||||
|
||||
const JobResult = mongoose.model("JobResult", JobResultScehma);
|
||||
|
||||
@@ -188,6 +188,7 @@ export default class JobQueueService extends Service {
|
||||
async "enqueue.async.completed"(ctx: Context<{ id: Number }>) {
|
||||
// 1. Fetch the job result using the job Id
|
||||
const job = await this.job(ctx.params.id);
|
||||
console.log(job);
|
||||
// 2. Increment the completed job counter
|
||||
await pubClient.incr("completedJobCount");
|
||||
// 3. Fetch the completed job count for the final payload to be sent to the client
|
||||
@@ -208,6 +209,7 @@ export default class JobQueueService extends Service {
|
||||
await JobResult.create({
|
||||
id: ctx.params.id,
|
||||
status: "completed",
|
||||
timestamp: job.timestamp,
|
||||
failedReason: {},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user