Update: User.ad v0.1
This commit is contained in:
parent
d564f7d8b3
commit
1dd527296c
1 changed files with 19 additions and 17 deletions
|
|
@ -380,23 +380,25 @@ exports.roles = (req, res) => {
|
||||||
|
|
||||||
// Get 1 or multiple ad adapted to the User session id
|
// Get 1 or multiple ad adapted to the User session id
|
||||||
exports.ad = (req, res) => {
|
exports.ad = (req, res) => {
|
||||||
// const token = checkLogin(req, res);
|
const token = checkLogin(req, res);
|
||||||
// if(token && typeof req.query.quantity !== 'undefined'){
|
if(token && typeof req.query.quantity !== 'undefined'){
|
||||||
// const id = token.id;
|
const id = token.id;
|
||||||
// const quantity = req.query.quantity;
|
const quantity = req.query.quantity;
|
||||||
// // Interests from the user and from last 20 videos viewed -> find x ad from these interests + add date view to the ad
|
// Interests from the user and from last 20 videos viewed -> find x ad from these interests + add date view to the ad
|
||||||
// let interests = ['Entertainments', ];
|
// let interests = ['Entertainments', 'Test'];
|
||||||
// Ad.aggregate([{$match: {'interests.interest': {$in: interests}}}])
|
// const match = {$match: {interests: {$in: interests}}};
|
||||||
// .then(data => {
|
const match = {$match: {}}
|
||||||
// return sendMessage(res, 11, data, token)
|
|
||||||
// })
|
Ad.aggregate([match, {$limit: parseInt(quantity, 10)}])
|
||||||
// .catch(err => {
|
.then(data => {
|
||||||
// return sendError(res,500,100,err.message || `Some error occurred while getting ${quantity} ad(s) for the User.`, token);
|
return sendMessage(res, 11, data, token)
|
||||||
// });
|
})
|
||||||
// } else {
|
.catch(err => {
|
||||||
// sendError(res, 500, -1, `No quantity given`, token);
|
return sendError(res,500,100,err.message || `Some error occurred while getting ${quantity} ad(s) for the User.`, token);
|
||||||
// }
|
});
|
||||||
return sendError(res, 501, -1, "User.ad not Implemented", null);
|
} else {
|
||||||
|
sendError(res, 500, -1, `No quantity given`, token);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get History
|
// Get History
|
||||||
|
|
|
||||||
Reference in a new issue