[AB-272] improving leaderboard performance

fixing leaderboard returning wrong pages
making template cache update duration longer
This commit is contained in:
Sheldan
2021-05-26 21:41:04 +02:00
parent 919b52a607
commit 95a639a733
16 changed files with 98 additions and 90 deletions

View File

@@ -15,6 +15,7 @@ import net.dv8tion.jda.api.entities.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
@@ -79,6 +80,19 @@ public class MemberServiceBean implements MemberService {
}
}
@Override
public CompletableFuture<List<Member>> getMembersInServerAsync(Long serverId, List<Long> memberIds) {
log.debug("Retrieving member {} in server {} from cache.", memberIds, serverId);
Guild guildById = guildService.getGuildById(serverId);
CompletableFuture<List<Member>> future = new CompletableFuture<>();
if(guildById != null) {
guildById.retrieveMembersByIds(memberIds).onSuccess(future::complete).onError(future::completeExceptionally);
} else {
throw new GuildNotFoundException(serverId);
}
return future;
}
@Override
public CompletableFuture<Member> retrieveMemberInServer(ServerUser serverUser) {
return getMemberInServerAsync(serverUser.getServerId(), serverUser.getUserId());

View File

@@ -49,6 +49,8 @@ public class FreemarkerConfiguration {
Configuration configuration = factory.createConfiguration();
configuration.setSharedVariable("fmtDuration", durationMethod);
configuration.setSharedVariable("formatDate", instantMethod);
// 10 minutes template cache
configuration.setTemplateUpdateDelayMilliseconds(600000);
List<String> macrosToLoad = macroManagementService.loadAllMacros().stream()
.map(AutoLoadMacro::getKey).collect(Collectors.toList());
configuration.setAutoIncludes(macrosToLoad);