mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-26 05:44:42 +00:00
[AB-272] improving leaderboard performance
fixing leaderboard returning wrong pages making template cache update duration longer
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user