Skip to content

Commit

Permalink
Remove unnecessary counters
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-vasconcelos committed Nov 7, 2023
1 parent 3c9e101 commit 073dfe7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions notifier/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const RUN_INTERVAL = 30000; // seconds
//

// Skip if already notified job owner
if (jobData.notification_count > 0) continue;
if (jobData.date_notified.length > 0) continue;

// Skip if job has no onwer email
if (!jobData.owner_email) continue;
Expand All @@ -56,7 +56,7 @@ const RUN_INTERVAL = 30000; // seconds
});

// Update status of this job
await QUEUEDB.Job.updateOne({ _id: jobData._id }, { $set: { notification_count: jobData.notification_count + 1, date_notified: [...jobData.date_notified, new Date().toISOString()] } });
await QUEUEDB.Job.updateOne({ _id: jobData._id }, { $set: { date_notified: [...jobData.date_notified, new Date().toISOString()] } });

// Log progress
console.log(`→ id: ${jobData._id} | owner_email: ${jobData.owner_email}`);
Expand Down
2 changes: 1 addition & 1 deletion server/endpoints/download.endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = async (request, reply) => {
if (!fs.existsSync(`${OUTPUT_DIRECTORY}/${foundRequestedJob._id}.pdf`)) return reply.code(404).send();

// Update download date for this job
await QUEUEDB.Job.updateOne({ _id: QUEUEDB.toObjectId(request.params.id) }, { $set: { download_count: foundRequestedJob.download_count + 1, date_downloaded: [...foundRequestedJob.date_downloaded, new Date().toISOString()] } });
await QUEUEDB.Job.updateOne({ _id: QUEUEDB.toObjectId(request.params.id) }, { $set: { date_downloaded: [...foundRequestedJob.date_downloaded, new Date().toISOString()] } });

// Read the file to the client
reply.header('Content-Type', 'application/pdf');
Expand Down
3 changes: 0 additions & 3 deletions server/endpoints/publish.endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ module.exports = async (request, reply) => {
const newRequestedJob = await QUEUEDB.Job.insertOne({
// Job status
status: 'registered',
// Counters
notification_count: 0,
download_count: 0,
// Timestamps
date_registered: new Date().toISOString(),
date_processing: null,
Expand Down

0 comments on commit 073dfe7

Please sign in to comment.