Fix ForumThread

This commit is contained in:
brenoepic 2022-04-29 22:25:04 -03:00
parent fc82db6dec
commit d54b9dba92

View File

@ -123,13 +123,13 @@ public class ForumThread implements Runnable, ISerialize {
THashSet<ForumThread> threads = null;
if (guildThreadsCache.containsKey(guildId)) {
guildThreadsCache.get(guildId);
threads = guildThreadsCache.get(guildId);
}
if (threads != null)
return threads;
threads = new THashSet<ForumThread>();
threads = new THashSet<>();
guildThreadsCache.put(guildId, threads);
@ -141,8 +141,8 @@ public class ForumThread implements Runnable, ISerialize {
"WHERE `id` IN (" +
"SELECT MAX(id) " +
"FROM `guilds_forums_comments` B " +
"GROUP BY `thread_id` " +
"ORDER BY B.`id` ASC " +
"GROUP BY `thread_id` AND B.`id` " +
"ORDER BY B.`id` " +
") " +
"ORDER BY `id` DESC " +
") B ON A.`id` = B.`thread_id` " +
@ -154,9 +154,7 @@ public class ForumThread implements Runnable, ISerialize {
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
ForumThread thread = new ForumThread(set);
synchronized (threads) {
threads.add(thread);
}
cacheThread(thread);
}
}
@ -182,8 +180,8 @@ public class ForumThread implements Runnable, ISerialize {
"WHERE `id` IN (" +
"SELECT MAX(id) " +
"FROM `guilds_forums_comments` B " +
"GROUP BY `thread_id` " +
"ORDER BY B.`id` ASC " +
"GROUP BY `thread_id` AND b.`id`" +
"ORDER BY B.`id` " +
") " +
"ORDER BY `id` DESC " +
") B ON A.`id` = B.`thread_id` " +
@ -219,10 +217,7 @@ public class ForumThread implements Runnable, ISerialize {
guildThreadsCache.put(thread.guildId, guildThreads);
}
}
synchronized (guildThreads) {
guildThreads.add(thread);
}
}
public static void clearCache() {