= Updated DB info

This commit is contained in:
Matthew Cech
2019-05-24 00:39:07 -07:00
parent 434ff1b46b
commit 634d67917f
8 changed files with 71 additions and 2 deletions
+2
View File
@@ -45,3 +45,5 @@ guildrolelist=1
benchmark, bench=1 benchmark, bench=1
bethistory=1 bethistory=1
crouton=1 crouton=1
dbstats=1
dbflush=1
+2
View File
@@ -20,6 +20,7 @@ perish, thenperish=
teey= teey=
guildrolelist= guildrolelist=
stats= stats=
dbstats=
beans= beans=
eightball, 8ball= eightball, 8ball=
catch= catch=
@@ -43,6 +44,7 @@ buildHelp=
fetch= fetch=
crouton= crouton=
invite= invite=
dbflush=
shutdown= shutdown=
+6
View File
@@ -138,6 +138,9 @@ RatingWarning=Warning: NSFW may slip through, images are only based on tags on t
RatingChanged=Kittybot content set to RatingChanged=Kittybot content set to
RatingInvalid=Invalid content rating RatingInvalid=Invalid content rating
[CommandDBStats]
DBStatsInfo=
[CommandGiveBeans] [CommandGiveBeans]
GiveBeansNoneMentioned=You didn't mention anyone! GiveBeansNoneMentioned=You didn't mention anyone!
GiveBeansSuccess=Gave %s %s beans! GiveBeansSuccess=Gave %s %s beans!
@@ -229,6 +232,9 @@ WolframError=Something went wrong!
WolframInfo=Will query wolframalpha with your question and give a full image output of the answer WolframInfo=Will query wolframalpha with your question and give a full image output of the answer
WolframNoArgs=You need to provide some arguments! WolframNoArgs=You need to provide some arguments!
[CommandDBFlush]
DBFlushInfo=
[CommandMap] [CommandMap]
MapInfo=Generates a map! You can pass additional information if you want with the flags `-s<seed>-w<width>-h<height>`. If one of the fields isn't provided, its default will be used. Note that adjusting the width and height impacts the map outcomes.\n\nDefault seed: Random,\nDefault Width: 35(max %s),\nDefault Height: 25(max %s) MapInfo=Generates a map! You can pass additional information if you want with the flags `-s<seed>-w<width>-h<height>`. If one of the fields isn't provided, its default will be used. Note that adjusting the width and height impacts the map outcomes.\n\nDefault seed: Random,\nDefault Width: 35(max %s),\nDefault Height: 25(max %s)
MapSeed=Seed MapSeed=Seed
+1 -1
View File
@@ -13,7 +13,7 @@ import dataStructures.KittyUser;
import dataStructures.Response; import dataStructures.Response;
import dataStructures.UserInput; import dataStructures.UserInput;
public class CommandCrouton extends Command public class CommandCrouton extends Command
{ {
public CommandCrouton(KittyRole level, KittyRating rating) { super(level, rating); } public CommandCrouton(KittyRole level, KittyRating rating) { super(level, rating); }
+1 -1
View File
@@ -28,7 +28,7 @@ public class CommandDBFlush extends Command
KittyEmbed embed = new KittyEmbed(); KittyEmbed embed = new KittyEmbed();
embed.title = "Database queue flushed"; embed.title = "Database queue flushed";
embed.descriptionText = "flushed: " + numUpdated; embed.descriptionText = "**Dirty:** " + numUpdated;
embed.color = new Color(7*16, 8*16, 9*16); embed.color = new Color(7*16, 8*16, 9*16);
res.CallEmbed(embed); res.CallEmbed(embed);
+43
View File
@@ -0,0 +1,43 @@
package commands;
import java.awt.Color;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import core.Command;
import core.DatabaseManager;
import core.LocStrings;
import dataStructures.KittyChannel;
import dataStructures.KittyEmbed;
import dataStructures.KittyGuild;
import dataStructures.KittyRating;
import dataStructures.KittyRole;
import dataStructures.KittyUser;
import dataStructures.Response;
import dataStructures.UserInput;
public class CommandDBStats extends Command
{
DateFormat dateFormat;
public CommandDBStats(KittyRole level, KittyRating rating)
{
super(level, rating);
dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
}
@Override
public String HelpText() { return LocStrings.Stub("DBStatsInfo"); }
@Override
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
{
KittyEmbed embed = new KittyEmbed();
embed.title = "Database Info";
embed.descriptionText = "**Tracked Items:** " + DatabaseManager.instance.GetTrackedObjectsSize();
embed.descriptionText += "\n";
embed.descriptionText += "**Last Upkeep:** " + dateFormat.format(DatabaseManager.instance.GetLastUpkeep()) + " UTC-7";
embed.color = new Color(7*16, 8*16, 9*16);
res.CallEmbed(embed);
}
}
+15
View File
@@ -1,5 +1,6 @@
package core; package core;
import java.util.Date;
import java.util.Vector; import java.util.Vector;
import utils.GlobalLog; import utils.GlobalLog;
import utils.LogFilter; import utils.LogFilter;
@@ -12,6 +13,7 @@ public class DatabaseManager
// Private internal variables // Private internal variables
private Vector<DatabaseTrackedObject> trackedObjects; private Vector<DatabaseTrackedObject> trackedObjects;
private DatabaseDriver driver; private DatabaseDriver driver;
private Date lastUpkeep;
public DatabaseManager() public DatabaseManager()
{ {
@@ -27,6 +29,7 @@ public class DatabaseManager
return; return;
} }
lastUpkeep = new Date();
trackedObjects = new Vector<DatabaseTrackedObject>(); trackedObjects = new Vector<DatabaseTrackedObject>();
driver = new DatabaseDriver(); driver = new DatabaseDriver();
@@ -57,6 +60,8 @@ public class DatabaseManager
} }
} }
lastUpkeep = new Date();
return numUpdated; return numUpdated;
} }
} }
@@ -85,4 +90,14 @@ public class DatabaseManager
driver.CreateSetKey(key, value); driver.CreateSetKey(key, value);
} }
} }
public Date GetLastUpkeep()
{
return lastUpkeep;
}
public int GetTrackedObjectsSize()
{
return trackedObjects.size();
}
} }
+1
View File
@@ -336,6 +336,7 @@ public class ObjectBuilderFactory
manager.Register(LocCommands.Stub("buildHelp"), new CommandHelpBuilder(KittyRole.Dev, KittyRating.Safe)); manager.Register(LocCommands.Stub("buildHelp"), new CommandHelpBuilder(KittyRole.Dev, KittyRating.Safe));
manager.Register(LocCommands.Stub("tweet"), new CommandTweet(KittyRole.Dev, KittyRating.Safe)); manager.Register(LocCommands.Stub("tweet"), new CommandTweet(KittyRole.Dev, KittyRating.Safe));
manager.Register(LocCommands.Stub("dbflush"), new CommandDBFlush(KittyRole.Dev, KittyRating.Safe)); manager.Register(LocCommands.Stub("dbflush"), new CommandDBFlush(KittyRole.Dev, KittyRating.Safe));
manager.Register(LocCommands.Stub("dbstats"), new CommandDBStats(KittyRole.Dev, KittyRating.Safe));
// Admin // Admin
manager.Register(LocCommands.Stub("rating"), new CommandRating(KittyRole.Admin, KittyRating.Safe)); manager.Register(LocCommands.Stub("rating"), new CommandRating(KittyRole.Admin, KittyRating.Safe));