From 861a23e67e7fff5723ea33206f5358e810f711f0 Mon Sep 17 00:00:00 2001 From: t123yh Date: Mon, 28 Aug 2017 16:27:01 +0800 Subject: [PATCH] Fix delete error. --- models/rating_calculation.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/rating_calculation.js b/models/rating_calculation.js index 46ed823..72f9ab8 100644 --- a/models/rating_calculation.js +++ b/models/rating_calculation.js @@ -52,11 +52,12 @@ class RatingCalculation extends Model { async delete() { const RatingHistory = syzoj.model('rating_history'); const histories = await RatingHistory.query(null, { - rating_calculation_id: this.rating_calculation_id + rating_calculation_id: this.id }); for (const history of histories) { await history.loadRelationships(); const user = history.user; + console.log("Destroying history for user " + user.id); await history.destroy(); const ratingItem = (await RatingHistory.findOne({ where: { user_id: user.id },