Fixed badge
This commit is contained in:
parent
55514b408b
commit
b771d54453
2 changed files with 3 additions and 3 deletions
|
|
@ -18,7 +18,7 @@ const Answer = mongoose.Schema(
|
|||
);
|
||||
|
||||
Answer.post('findOneAndUpdate', (doc) => {
|
||||
const badges = calculateAnswerBadges(doc.points);
|
||||
const badges = calculateAnswerBadges(doc.upvotes - doc.downvotes);
|
||||
|
||||
User.findOneAndUpdate({ username: doc.creator }, { $addToSet: { tags: { $each: badges } } });
|
||||
});
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@ const Question = mongoose.Schema(
|
|||
title: { type: String, required: true },
|
||||
upvotes: { type: Number, required: true, default: 0 },
|
||||
views: { type: Number, required: true, default: 0 },
|
||||
hasBounty: {type: Number, required: false}
|
||||
hasBounty: { type: Number, required: false },
|
||||
},
|
||||
{ timestamps: { createdAt: false, updatedAt: true } }
|
||||
);
|
||||
|
||||
Question.post('findOneAndUpdate', (doc) => {
|
||||
const badges = calculateQuestionBadges(doc.points);
|
||||
const badges = calculateQuestionBadges(doc.upvotes - doc.downvotes);
|
||||
|
||||
User.findOneAndUpdate({ username: doc.creator }, { $addToSet: { tags: { $each: badges } } });
|
||||
});
|
||||
|
|
|
|||
Reference in a new issue