remove caching until i can find a good solution
Some checks failed
Deploy to Dokku / docker (ubuntu-latest) (push) Failing after 17s

This commit is contained in:
Lee 2024-06-26 16:17:57 +01:00
parent 805da78cad
commit 4d891e1825
13 changed files with 27 additions and 32 deletions

@ -85,10 +85,6 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId> <artifactId>spring-boot-starter-websocket</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- Libraries --> <!-- Libraries -->
<dependency> <dependency>
@ -114,10 +110,6 @@
<artifactId>httpclient5</artifactId> <artifactId>httpclient5</artifactId>
<version>5.3.1</version> <version>5.3.1</version>
</dependency> </dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<!-- Test Dependencies --> <!-- Test Dependencies -->
<dependency> <dependency>

@ -7,7 +7,6 @@ import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import java.io.File; import java.io.File;
@ -15,7 +14,7 @@ import java.nio.file.Files;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
import java.util.Objects; import java.util.Objects;
@EnableCaching @EnableScheduling @EnableScheduling
@SpringBootApplication @SpringBootApplication
@Log4j2(topic = "Ember") @Log4j2(topic = "Ember")
public class BatApplication { public class BatApplication {

@ -4,12 +4,14 @@ import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.io.Serializable;
/** /**
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@AllArgsConstructor @AllArgsConstructor
@Getter @Setter @Getter @Setter
public abstract class Profile { public abstract class Profile implements Serializable {
/** /**
* The key of the profile. * The key of the profile.
*/ */

@ -2,6 +2,7 @@ package cc.fascinated.bat.common;
import lombok.Getter; import lombok.Getter;
import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -9,7 +10,7 @@ import java.util.Map;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Getter @Getter
public class ProfileHolder { public class ProfileHolder implements Serializable {
/** /**
* The profiles for the holder * The profiles for the holder
*/ */

@ -6,6 +6,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import net.dv8tion.jda.api.entities.Role; import net.dv8tion.jda.api.entities.Role;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -13,7 +14,7 @@ import java.util.List;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Setter @Getter @Setter @Getter
public class AutoRoleProfile extends Profile { public class AutoRoleProfile extends Profile implements Serializable {
private static final int DEFAULT_MAX_ROLES = 10; private static final int DEFAULT_MAX_ROLES = 10;
/** /**

@ -9,6 +9,7 @@ import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import java.io.Serializable;
import java.util.*; import java.util.*;
/** /**
@ -16,7 +17,7 @@ import java.util.*;
*/ */
@Getter @Getter
@Setter @Setter
public class BirthdayProfile extends Profile { public class BirthdayProfile extends Profile implements Serializable {
private static final String DEFAULT_MESSAGE = "Happy Birthday {user} :tada: :birthday: You are now {age} years old!"; private static final String DEFAULT_MESSAGE = "Happy Birthday {user} :tada: :birthday: You are now {age} years old!";
/** /**

@ -6,11 +6,13 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import java.io.Serializable;
/** /**
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Getter @Setter @Getter @Setter
public class GuildNumberOneScoreFeedProfile extends Profile { public class GuildNumberOneScoreFeedProfile extends Profile implements Serializable {
/** /**
* The channel ID of the score feed * The channel ID of the score feed
*/ */

@ -6,6 +6,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -13,7 +14,7 @@ import java.util.List;
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Getter @Setter @Getter @Setter
public class GuildUserScoreFeedProfile extends Profile { public class GuildUserScoreFeedProfile extends Profile implements Serializable {
/** /**
* The channel ID of the score feed * The channel ID of the score feed
*/ */

@ -4,11 +4,13 @@ import cc.fascinated.bat.common.Profile;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.io.Serializable;
/** /**
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Setter @Getter @Setter @Getter
public class UserScoreSaberProfile extends Profile { public class UserScoreSaberProfile extends Profile implements Serializable {
/** /**
* The Account ID of the ScoreSaber profile * The Account ID of the ScoreSaber profile
*/ */

@ -26,7 +26,8 @@ import java.util.Map;
/** /**
* @author Fascinated (fascinated7) * @author Fascinated (fascinated7)
*/ */
@Service @Log4j2 @Service
@Log4j2
@DependsOn("discordService") @DependsOn("discordService")
public class CommandService extends ListenerAdapter { public class CommandService extends ListenerAdapter {
/** /**
@ -139,8 +140,10 @@ public class CommandService extends ListenerAdapter {
} }
if (!missingPermissions.isEmpty()) { if (!missingPermissions.isEmpty()) {
event.replyEmbeds(EmbedUtils.errorEmbed() event.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("You are missing the following permissions to execute this command: " + missingPermissions) .setDescription("You are missing the following permissions to execute this command: " + missingPermissions)
.build()).queue(); .build())
.setEphemeral(true)
.queue();
return; return;
} }
} }
@ -150,8 +153,9 @@ public class CommandService extends ListenerAdapter {
log.error("An error occurred while executing command \"{}\"", commandName, ex); log.error("An error occurred while executing command \"{}\"", commandName, ex);
event.replyEmbeds(EmbedUtils.successEmbed() event.replyEmbeds(EmbedUtils.successEmbed()
.setDescription("An error occurred while executing the command\n\n" + ex.getLocalizedMessage()) .setDescription("An error occurred while executing the command\n\n" + ex.getLocalizedMessage())
.build()).queue(); .build())
.queue();
} }
} }
} }

@ -7,8 +7,6 @@ import lombok.extern.log4j.Log4j2;
import net.dv8tion.jda.api.events.guild.GuildJoinEvent; import net.dv8tion.jda.api.events.guild.GuildJoinEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter; import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.DependsOn; import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -38,7 +36,6 @@ public class GuildService extends ListenerAdapter {
* @param id The ID of the guild * @param id The ID of the guild
* @return The guild * @return The guild
*/ */
@Cacheable(cacheNames = {"guilds"}, key = "#id")
public BatGuild getGuild(@NonNull String id) { public BatGuild getGuild(@NonNull String id) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Optional<BatGuild> optionalGuild = guildRepository.findById(id); Optional<BatGuild> optionalGuild = guildRepository.findById(id);
@ -55,7 +52,6 @@ public class GuildService extends ListenerAdapter {
* *
* @param guild The guild to save * @param guild The guild to save
*/ */
@CachePut(cacheNames = {"guilds"}, key = "#guild.id")
public void saveGuild(@NonNull BatGuild guild) { public void saveGuild(@NonNull BatGuild guild) {
guildRepository.save(guild); guildRepository.save(guild);
} }

@ -13,7 +13,6 @@ import lombok.NonNull;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.TextMessage;
@ -44,7 +43,6 @@ public class ScoreSaberService extends TextWebSocketHandler {
* @throws ResourceNotFoundException If the account is not found. * @throws ResourceNotFoundException If the account is not found.
* @throws cc.fascinated.bat.exception.RateLimitException If the ScoreSaber rate limit is reached. * @throws cc.fascinated.bat.exception.RateLimitException If the ScoreSaber rate limit is reached.
*/ */
@Cacheable(cacheNames = "scoreSaberAccounts", key = "#id")
public ScoreSaberAccountToken getAccount(String id) { public ScoreSaberAccountToken getAccount(String id) {
ScoreSaberAccountToken account = WebRequest.getAsEntity(String.format(GET_PLAYER_ENDPOINT, id), ScoreSaberAccountToken.class); ScoreSaberAccountToken account = WebRequest.getAsEntity(String.format(GET_PLAYER_ENDPOINT, id), ScoreSaberAccountToken.class);
if (account == null) { // Check if the account doesn't exist. if (account == null) { // Check if the account doesn't exist.

@ -5,8 +5,6 @@ import cc.fascinated.bat.repository.UserRepository;
import lombok.NonNull; import lombok.NonNull;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.DependsOn; import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -34,7 +32,6 @@ public class UserService {
* @param id The ID of the user * @param id The ID of the user
* @return The user * @return The user
*/ */
@Cacheable(cacheNames = {"users"}, key = "#id")
public BatUser getUser(@NonNull String id) { public BatUser getUser(@NonNull String id) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Optional<BatUser> optionalUser = userRepository.findById(id); Optional<BatUser> optionalUser = userRepository.findById(id);
@ -51,7 +48,6 @@ public class UserService {
* *
* @param user The user to save * @param user The user to save
*/ */
@CachePut(cacheNames = {"users"}, key = "#user.id")
public void saveUser(@NonNull BatUser user) { public void saveUser(@NonNull BatUser user) {
userRepository.save(user); userRepository.save(user);
} }