Update: User.ad

This commit is contained in:
Yûki VACHOT 2021-12-15 02:08:18 +01:00
parent a6b1828c4b
commit a369177e19

View file

@ -412,13 +412,12 @@ exports.ad = (req, res) => {
} }
let match, pick; let match, pick;
if(interests.length > 0){ if(interests.length > 0){
match = {$match: {isVisible: true, isActive: true, interests: {$in: interests}}}; match = {$match: {isVisible: true, isActive: true, interests: {$elemMatch: {interest: {$in: interests}}}}};
pick = {$limit: parseInt(quantity, 10)} pick = {$limit: parseInt(quantity, 10)}
} else { } else {
match = {$match: {isVisible: true, isActive: true}}; match = {$match: {isVisible: true, isActive: true}};
pick = {$sample: {size: parseInt(quantity, 10)}}; pick = {$sample: {size: parseInt(quantity, 10)}};
} }
console.log(match, pick, interests);
Ad.aggregate([ Ad.aggregate([
match, match,
pick pick