Add vote statistics feature and improve vote page functionality

This commit is contained in:
2025-10-24 19:39:08 +02:00
parent 41dab473b0
commit 00bf7caec2
16 changed files with 447 additions and 80 deletions
@@ -7,7 +7,8 @@ public enum Databases {
DEFAULT("web_db"),
LUCK_PERMS("luckperms"),
LITE_BANS("litebans"),
DISCORD("discordLink");
DISCORD("discordLink"),
VOTING_PLUGIN("votingplugin");
private final String internalName;
@@ -0,0 +1,28 @@
package com.alttd.altitudeweb.database.votingplugin;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.Optional;
import java.util.UUID;
public interface VotingPluginUsersMapper {
@Select("""
SELECT
LastVotes as lastVotes,
BestDayVoteStreak as bestDailyStreak,
BestWeekVoteStreak as bestWeeklyStreak,
BestMonthVoteStreak as bestMonthlyStreak,
DayVoteStreak as dailyStreak,
WeekVoteStreak as weeklyStreak,
MonthVoteStreak as monthlyStreak,
DailyTotal as totalVotesToday,
WeeklyTotal as totalVotesThisWeek,
MonthTotal as totalVotesThisMonth,
AllTimeTotal as totalVotesAllTime
FROM votingplugin.votingplugin_users
WHERE uuid = #{uuid}
""")
Optional<VotingStatsRow> getStatsByUuid(@Param("uuid") UUID uuid);
}
@@ -0,0 +1,15 @@
package com.alttd.altitudeweb.database.votingplugin;
public record VotingStatsRow(
String lastVotes,
Integer bestDailyStreak,
Integer bestWeeklyStreak,
Integer bestMonthlyStreak,
Integer dailyStreak,
Integer weeklyStreak,
Integer monthlyStreak,
Integer totalVotesToday,
Integer totalVotesThisWeek,
Integer totalVotesThisMonth,
Integer totalVotesAllTime
) { }
@@ -38,6 +38,7 @@ public class Connection {
InitializeLiteBans.init();
InitializeLuckPerms.init();
InitializeDiscord.init();
InitializeVotingPlugin.init();
}
@FunctionalInterface
@@ -0,0 +1,17 @@
package com.alttd.altitudeweb.setup;
import com.alttd.altitudeweb.database.Databases;
import com.alttd.altitudeweb.database.votingplugin.VotingPluginUsersMapper;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class InitializeVotingPlugin {
protected static void init() {
log.info("Initializing VotingPlugin");
Connection.getConnection(Databases.VOTING_PLUGIN, (configuration) -> {
configuration.addMapper(VotingPluginUsersMapper.class);
}).join();
log.debug("Initialized VotingPlugin");
}
}