jobscraper/server/controllers/apply.v2.controller.js
2020-09-10 19:42:17 +01:00

82 lines
1.7 KiB
JavaScript

/**
* Created by WebStorm.
* User: martin
* Date: 10/09/2020
* Time: 16:07
*/
const Jobs = require('../../lib/mongoManager');
const { Utils } = require('@rakh/utils');
exports.markApplied = (req, res) => {
console.log('>V2 markApplied req', req.params);
if(!req.params.id)
return res.status(500).send({
'message': 'Job id missing'
});
const aid = req.params.id;
const now = new Date().getTime();
// touchOne
console.log('aid', aid);
Jobs.updateMany({ '_id':aid }, { '$set': { 'data.applied':now } } ).then((data) => {
console.log(data);
res.status(200).end();
}).catch((err) => {
console.error(err.message);
res.status(500).send({
'message': err.message || 'Some error occurred while querying the database.'
});
});
/*
dbmanager.appliedOne({ aid, a })
.then((data) => {
console.log(data);
res.status(200).end();
})
.catch((err) => {
res.status(500).send({
'message': err.message || 'Some error occurred while querying the database.'
});
});
*/
};
exports.markAllRead = (req, res) => {
console.log('>V2 markAllRead req', req.params);
const now = new Date().getTime();
Jobs.updateMany({ 'data.read':0 }, { '$set': { 'data.read':now } } ).then((data) => {
console.log(data);
res.status(200).end();
}).catch((err) => {
console.error(err.message);
res.status(500).send({
'message': err.message || 'Some error occurred while querying the database.'
});
});
/*
dbmanager.markAllRead()
.then((data) => {
console.log(data);
res.status(200).end();
})
.catch((err) => {
res.status(500).send({
'message': err.message || 'Some error occurred while querying the database.'
});
});
*/
};