1010import net .discordjug .javabot .data .config .BotConfig ;
1111import net .discordjug .javabot .systems .help .HelpExperienceService ;
1212import net .discordjug .javabot .systems .help .model .HelpAccount ;
13- import net .discordjug .javabot .systems .moderation .warn . dao . WarnRepository ;
13+ import net .discordjug .javabot .systems .moderation .ModerationService ;
1414import net .discordjug .javabot .systems .qotw .QOTWPointsService ;
1515import net .discordjug .javabot .systems .qotw .model .QOTWAccount ;
1616import net .discordjug .javabot .util .Pair ;
2929
3030import java .sql .Connection ;
3131import java .sql .SQLException ;
32- import java .time .LocalDateTime ;
3332import java .util .concurrent .TimeUnit ;
3433
3534import javax .sql .DataSource ;
@@ -44,7 +43,7 @@ public class UserProfileController extends CaffeineCache<Pair<Long, Long>, UserP
4443 private final DataSource dataSource ;
4544 private final BotConfig botConfig ;
4645 private final HelpExperienceService helpExperienceService ;
47- private final WarnRepository warnRepository ;
46+ private final ModerationService moderationService ;
4847
4948 /**
5049 * The constructor of this class which initializes the {@link Caffeine} cache.
@@ -54,10 +53,10 @@ public class UserProfileController extends CaffeineCache<Pair<Long, Long>, UserP
5453 * @param botConfig The main configuration of the bot
5554 * @param dataSource A factory for connections to the main database
5655 * @param helpExperienceService Service object that handles Help Experience Transactions.
57- * @param warnRepository DAO for interacting with the set of {@link Warn} objects.
56+ * @param moderationService Service object for moderating members
5857 */
5958 @ Autowired
60- public UserProfileController (final JDA jda , QOTWPointsService qotwPointsService , BotConfig botConfig , DataSource dataSource , HelpExperienceService helpExperienceService , WarnRepository warnRepository ) {
59+ public UserProfileController (final JDA jda , QOTWPointsService qotwPointsService , BotConfig botConfig , DataSource dataSource , HelpExperienceService helpExperienceService , ModerationService moderationService ) {
6160 super (Caffeine .newBuilder ()
6261 .expireAfterWrite (10 , TimeUnit .MINUTES )
6362 .build ()
@@ -67,7 +66,7 @@ public UserProfileController(final JDA jda, QOTWPointsService qotwPointsService,
6766 this .dataSource = dataSource ;
6867 this .botConfig = botConfig ;
6968 this .helpExperienceService = helpExperienceService ;
70- this .warnRepository = warnRepository ;
69+ this .moderationService = moderationService ;
7170 }
7271
7372 /**
@@ -108,8 +107,7 @@ public ResponseEntity<UserProfileData> getUserProfile(
108107 HelpAccount helpAccount = helpExperienceService .getOrCreateAccount (user .getIdLong ());
109108 data .setHelpAccount (HelpAccountData .of (botConfig , helpAccount , guild ));
110109 // User Warns
111- LocalDateTime cutoff = LocalDateTime .now ().minusDays (botConfig .get (guild ).getModerationConfig ().getWarnTimeoutDays ());
112- data .setWarns (warnRepository .getActiveWarnsByUserId (user .getIdLong (), cutoff ));
110+ data .setWarns (moderationService .getTotalSeverityWeight (guild , user .getIdLong ()).contributingWarns ());
113111 // Insert into cache
114112 getCache ().put (new Pair <>(guild .getIdLong (), user .getIdLong ()), data );
115113 }
0 commit comments