From eb967704bcea070ac732a9d5803267f90c6669cd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 12 May 2023 11:56:27 +0200 Subject: [PATCH 1/3] Update postgres Docker tag to v15.3 (#526) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- docker/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 6828334a0..11d45f89f 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -12,7 +12,7 @@ services: database: networks: - repbot - image: postgres:15.2 + image: postgres:15.3 expose: - 5432 volumes: From 83c67828da03a78f1970e01eb231abfa722c4890 Mon Sep 17 00:00:00 2001 From: Lilly Tempest <46890129+rainbowdashlabs@users.noreply.github.com> Date: Mon, 29 May 2023 13:30:49 +0200 Subject: [PATCH 2/3] Enhance gdpr logging and user prune performance (#527) --- .../repbot/commands/gdpr/handler/Delete.java | 4 +++ .../repbot/commands/prune/handler/Guild.java | 4 +++ .../repbot/dao/access/gdpr/GdprUser.java | 1 + .../guild/reputation/sub/user/Gdpr.java | 6 +++++ .../de/chojo/repbot/service/GdprService.java | 27 ++++++++++++------- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/chojo/repbot/commands/gdpr/handler/Delete.java b/src/main/java/de/chojo/repbot/commands/gdpr/handler/Delete.java index 8f5fdf600..c3a06510e 100644 --- a/src/main/java/de/chojo/repbot/commands/gdpr/handler/Delete.java +++ b/src/main/java/de/chojo/repbot/commands/gdpr/handler/Delete.java @@ -4,9 +4,13 @@ import de.chojo.jdautil.wrapper.EventContext; import de.chojo.repbot.dao.access.Gdpr; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import org.slf4j.Logger; + +import static org.slf4j.LoggerFactory.getLogger; public class Delete implements SlashHandler { private final Gdpr gdpr; + private static final Logger log = getLogger(Delete.class); public Delete(Gdpr gdpr) { this.gdpr = gdpr; diff --git a/src/main/java/de/chojo/repbot/commands/prune/handler/Guild.java b/src/main/java/de/chojo/repbot/commands/prune/handler/Guild.java index 185ff9649..c88ae8f84 100644 --- a/src/main/java/de/chojo/repbot/commands/prune/handler/Guild.java +++ b/src/main/java/de/chojo/repbot/commands/prune/handler/Guild.java @@ -5,8 +5,12 @@ import de.chojo.jdautil.wrapper.EventContext; import de.chojo.repbot.service.GdprService; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import org.slf4j.Logger; + +import static org.slf4j.LoggerFactory.getLogger; public class Guild implements SlashHandler { + private static final Logger log = getLogger(Guild.class); private final GdprService service; public Guild(GdprService service) { diff --git a/src/main/java/de/chojo/repbot/dao/access/gdpr/GdprUser.java b/src/main/java/de/chojo/repbot/dao/access/gdpr/GdprUser.java index fde8bc8b8..ea0636f91 100644 --- a/src/main/java/de/chojo/repbot/dao/access/gdpr/GdprUser.java +++ b/src/main/java/de/chojo/repbot/dao/access/gdpr/GdprUser.java @@ -45,6 +45,7 @@ public static GdprUser build(Gdpr gdpr, Row rs, ShardManager shardManager) throw } public boolean queueDeletion() { + log.info("User {} requested deletion of their data", userId()); return builder() .query(""" INSERT INTO diff --git a/src/main/java/de/chojo/repbot/dao/access/guild/reputation/sub/user/Gdpr.java b/src/main/java/de/chojo/repbot/dao/access/guild/reputation/sub/user/Gdpr.java index ddc6cc102..b49d3116e 100644 --- a/src/main/java/de/chojo/repbot/dao/access/guild/reputation/sub/user/Gdpr.java +++ b/src/main/java/de/chojo/repbot/dao/access/guild/reputation/sub/user/Gdpr.java @@ -7,9 +7,13 @@ import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.User; +import org.slf4j.Logger; + +import static org.slf4j.LoggerFactory.getLogger; public class Gdpr extends QueryFactory implements MemberHolder { private final RepUser repUser; + private static final Logger log = getLogger(Gdpr.class); public Gdpr(RepUser repUser) { super(repUser); @@ -22,6 +26,7 @@ public Member member() { } public void queueDeletion() { + log.info("User {} is scheduled for deletion on guild {}", userId(), guildId()); builder() .query(""" INSERT INTO @@ -38,6 +43,7 @@ ON CONFLICT(guild_id, user_id) } public void dequeueDeletion() { + log.info("User {} deletion on guild {} canceled", userId(), guildId()); builder() .query(""" DELETE FROM diff --git a/src/main/java/de/chojo/repbot/service/GdprService.java b/src/main/java/de/chojo/repbot/service/GdprService.java index 69b27d074..fdca4745e 100644 --- a/src/main/java/de/chojo/repbot/service/GdprService.java +++ b/src/main/java/de/chojo/repbot/service/GdprService.java @@ -2,13 +2,13 @@ import de.chojo.repbot.dao.access.Gdpr; import de.chojo.repbot.dao.access.gdpr.RemovalTask; -import de.chojo.repbot.dao.access.guild.RepGuild; import de.chojo.repbot.dao.provider.Guilds; import net.dv8tion.jda.api.entities.Guild; -import net.dv8tion.jda.api.entities.ISnowflake; import net.dv8tion.jda.api.sharding.ShardManager; import org.slf4j.Logger; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.ScheduledExecutorService; @@ -60,17 +60,26 @@ public void run() { public CompletableFuture cleanupGuildUsers(Guild guild) { return CompletableFuture.supplyAsync(() -> { - var savedIds = guilds.guild(guild).userIds(); - var memberIds = guild.loadMembers().get() - .stream() - .map(ISnowflake::getIdLong).toList(); - var collect = savedIds.stream().filter(id -> !memberIds.contains(id)).toList(); - for (var id : collect) RemovalTask.anonymExecute(gdpr, guild.getIdLong(), id); - return collect.size(); + log.info("Guild prune was started on {}", guild.getId()); + var pruned = 0; + var users = guilds.guild(guild).userIds(); + log.info("Checking {} users", users.size()); + for (var user : users) { + try { + guild.retrieveMemberById(user).complete(); + } catch (RuntimeException e) { + log.info("Removing user {} data during guild prune", user); + RemovalTask.anonymExecute(gdpr, guild.getIdLong(), user); + pruned++; + } + } + log.info("Prune on guild {} finished. Removed {} users", guild.getId(), pruned); + return pruned; }, executorService); } public void cleanupGuildUser(Guild guild, Long user) { + log.info("User data of {} was pruned on guild {}.", user, guild.getIdLong()); CompletableFuture.runAsync(() -> RemovalTask.anonymExecute(gdpr, guild.getIdLong(), user), executorService); } From c8cfb4e16d0199a0b47c3c3fa21c5a2ee3a8a367 Mon Sep 17 00:00:00 2001 From: Lilly Tempest <46890129+rainbowdashlabs@users.noreply.github.com> Date: Tue, 30 May 2023 10:01:01 +0200 Subject: [PATCH 3/3] Update build.gradle.kts --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4416c0df7..a27661d87 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } group = "de.chojo" -version = "1.13.15" +version = "1.13.16" repositories { maven("https://eldonexus.de/repository/maven-public")