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