From 5db2d80971cfddb544399cb3570b9556c32138fb Mon Sep 17 00:00:00 2001 From: Matthew Cech Date: Wed, 19 Jun 2019 21:17:30 -0700 Subject: [PATCH] = Updated stats formatting --- src/commands/CommandStats.java | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/commands/CommandStats.java b/src/commands/CommandStats.java index b7211be..1eea9e7 100644 --- a/src/commands/CommandStats.java +++ b/src/commands/CommandStats.java @@ -3,7 +3,9 @@ package commands; import core.Command; import core.LocStrings; import core.CommandManager.ThreadData; +import core.Config; import dataStructures.KittyChannel; +import dataStructures.KittyEmbed; import dataStructures.KittyGuild; import dataStructures.KittyRating; import dataStructures.KittyRole; @@ -23,25 +25,30 @@ public class CommandStats extends Command @Override public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res) { - String out = "```\n"; + // Variables Stats stats = Stats.instance; - + String out = ""; long seen = stats.GetMessagesSeen(); long processed = stats.GetCommandsProcessed(); - out += "----- [General] -----\n"; + // General + out += "General"; + out += "```\n"; out += " Messages observed: " + seen + "\n"; out += "Commands processed: " + processed + "\n"; out += " Command invoke %: " + ((int)((processed / (float)seen) * 1000)) / 10.0f + "%\n"; - out += " KittyBot uptime: " + stats.GetFormattedUptime() + "\n"; - out += "\n"; - out += "----- [Health] -----\n"; + out += " Bot uptime: " + stats.GetFormattedUptime() + "\n"; + out += "```\n"; + + // Health + out += "Health"; + out += "```\n"; out += " SMT cores: " + stats.GetCPUAvailable() + "\n"; - // If CPU load works on this OS, list it. + // If CPU load works on this OS, list it. -1.0 is the error state double CPULoad = stats.GetSystemCPULoad(); - if(CPULoad > -0.9) // -1.0 is the error state - out += "System CPU Load: " + (CPULoad * 100) + "%\n"; + out += CPULoad > -0.9 + ? " CPU Load: " + (CPULoad * 100) + "%\n" : ""; ThreadData data = stats.GetThreadData(); Integer terminated = data.states.get(Thread.State.TERMINATED); @@ -58,12 +65,18 @@ public class CommandStats extends Command + " term-" + (terminated == null ? 0 : terminated) + "\n"; + out += "```\n"; + + + // Cache Integer guildCount = stats.GetGuildCount(); Integer userCount = stats.GetUserCount(); - out += "\n----- [Cache] -----\n" + out += "Cache"; + out += "```\n" + "Cached Guilds: " + guildCount + "\n" + " Cached Users: " + userCount; + out += "\n```"; KittyEmbed embed = new KittyEmbed();