You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -106,7 +107,46 @@ public void warn(User user, WarnSeverity severity, String reason, Member warnedB
106
107
}
107
108
});
108
109
}
109
-
110
+
111
+
/**
112
+
* Gets the total warn severity weight of a given user.
113
+
* @implSpec
114
+
* Only warns from the last {@link ModerationConfig#getMaxWarnValidityDays()} days are checked.
115
+
* Every {@link ModerationConfig#getWarnDecayDays()} days, {@link ModerationConfig#getWarnDecayAmount()} of severity are subtracted from the total severity of the user.
116
+
* This method does not allow negative severities at any point in time.
117
+
* The oldest considered warn decides on the amount of severity to subtract.
118
+
* Hence, all warns that would (together) not increase the severity due to being too old are ignored.
119
+
* @implNote
120
+
* The total severity is calculated per warn by considering the severity of all warns after the given warn and subtracting the discount subtrahend corresponding to the given (oldest) warn from the severity.
121
+
* Then, the maximum discounted severity over all warns is chosen.
122
+
* @param userId the ID of the user to check
123
+
* @return the accumulated warn severity weight of the user along with all warns contributing to it.
builder.appendDescription("(Due to warn decay, the total severity is `"+severityInformation.severityDiscount()+"` lower than the sum of all warn severities.)\n");
returnjdbcTemplate.queryForObject("SELECT SUM(severity_weight) FROM warn WHERE user_id = ? AND discarded = FALSE AND created_at > ?", (rs, rows)->rs.getInt(1),
77
-
userId, Timestamp.valueOf(cutoff));
78
-
}catch (EmptyResultDataAccessExceptione) {
79
-
return0;
80
-
}
81
-
}
82
-
64
+
83
65
/**
84
66
* Discards all warnings that have been issued to a given user.
returnjdbcTemplate.query("SELECT * FROM warn WHERE user_id = ? AND discarded = FALSE AND created_at > ?",(rs, row)->this.read(rs),
120
+
returnjdbcTemplate.query("SELECT * FROM warn WHERE user_id = ? AND discarded = FALSE AND created_at > ? ORDER BY created_at DESC",(rs, row)->this.read(rs),
0 commit comments