From 5540bb16ecbdfb1faf9fafbd816104d780700a26 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Thu, 24 Aug 2023 09:06:38 -0500 Subject: [PATCH] =?UTF-8?q?=E2=8F=B1=EF=B8=8F=20Added=20a=20timestamp=20to?= =?UTF-8?q?=20job=20results=20schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/jobresult.model.ts | 3 ++- services/jobqueue.service.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/models/jobresult.model.ts b/models/jobresult.model.ts index 98f7de4..01233e9 100644 --- a/models/jobresult.model.ts +++ b/models/jobresult.model.ts @@ -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); diff --git a/services/jobqueue.service.ts b/services/jobqueue.service.ts index fe3c7d3..7f9d807 100644 --- a/services/jobqueue.service.ts +++ b/services/jobqueue.service.ts @@ -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: {}, });