|
|
@ -52,11 +52,12 @@ class RatingCalculation extends Model { |
|
|
|
async delete() { |
|
|
|
async delete() { |
|
|
|
const RatingHistory = syzoj.model('rating_history'); |
|
|
|
const RatingHistory = syzoj.model('rating_history'); |
|
|
|
const histories = await RatingHistory.query(null, { |
|
|
|
const histories = await RatingHistory.query(null, { |
|
|
|
rating_calculation_id: this.rating_calculation_id |
|
|
|
rating_calculation_id: this.id |
|
|
|
}); |
|
|
|
}); |
|
|
|
for (const history of histories) { |
|
|
|
for (const history of histories) { |
|
|
|
await history.loadRelationships(); |
|
|
|
await history.loadRelationships(); |
|
|
|
const user = history.user; |
|
|
|
const user = history.user; |
|
|
|
|
|
|
|
console.log("Destroying history for user " + user.id); |
|
|
|
await history.destroy(); |
|
|
|
await history.destroy(); |
|
|
|
const ratingItem = (await RatingHistory.findOne({ |
|
|
|
const ratingItem = (await RatingHistory.findOne({ |
|
|
|
where: { user_id: user.id }, |
|
|
|
where: { user_id: user.id }, |
|
|
|