quick fix

This commit is contained in:
Sebastien 2018-12-14 01:23:49 +02:00
parent bb08e3b614
commit 352a87a1f3
2 changed files with 11 additions and 1 deletions

View File

@ -159,7 +159,12 @@ public class MusicWebAPIController {
logger.info("Receive command " + data.command + " from " + request.getRemoteAddr() + " USER: " + user.getName() + " GUILD: " + guild.getName());
if (ApiCommandLoader.apiCommands.containsKey(data.command)) {
try {
UserStatsUtils.getINSTANCE().addApiCount(user, guildId);
}catch (IndexOutOfBoundsException e){
logger.catching(e);
}
return ApiCommandLoader.apiCommands.get(data.command).action(data, MainBot.jda.getUserById(user.getJdaId()), guild);
}
else

View File

@ -45,6 +45,8 @@ public class UserStatsUtils {
}
public List<UserStats> getUserStats(UserEntity userEntity){
logger.debug(userEntity.getUserStats());
logger.debug(userEntity.getUserStats().size());
if(userEntity.getUserStats() == null || userEntity.getUserStats().size() == 0){
logger.debug("Stats not found for " + userEntity.getName());
User user = MainBot.jda.getUserById(userEntity.getJdaId());
@ -90,10 +92,12 @@ public class UserStatsUtils {
userEntity = userEntityList.get(0);
List<UserStats> userStatsList = userStatsRepository.findByUserAndGuildId(userEntity, member.getGuild().getId());
logger.debug("First: " + userStatsList.size());
if(userStatsList.size() == 0){
getUserStats(userEntity);
userStatsList = userStatsRepository.findByUserAndGuildId(userEntity, member.getGuild().getId());
}
UserStats userStats = userStatsList.get(0);
userStats.setMessageCount(userStats.getMessageCount() + 1);
userStatsRepository.save(userStats);
@ -105,6 +109,7 @@ public class UserStatsUtils {
List<UserStats> userStatsList = userStatsRepository.findByUserAndGuildId(userEntity, guildId);
logger.debug("First: " + userStatsList.size());
if(userStatsList.size() == 0){
getUserStats(userEntity);
userStatsList = userStatsRepository.findByUserAndGuildId(userEntity, guildId);