= Updated DB info
This commit is contained in:
@@ -13,7 +13,7 @@ import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandCrouton extends Command
|
||||
public class CommandCrouton extends Command
|
||||
{
|
||||
public CommandCrouton(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public class CommandDBFlush extends Command
|
||||
|
||||
KittyEmbed embed = new KittyEmbed();
|
||||
embed.title = "Database queue flushed";
|
||||
embed.descriptionText = "flushed: " + numUpdated;
|
||||
embed.descriptionText = "**Dirty:** " + numUpdated;
|
||||
embed.color = new Color(7*16, 8*16, 9*16);
|
||||
|
||||
res.CallEmbed(embed);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package core;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Vector;
|
||||
import utils.GlobalLog;
|
||||
import utils.LogFilter;
|
||||
@@ -12,6 +13,7 @@ public class DatabaseManager
|
||||
// Private internal variables
|
||||
private Vector<DatabaseTrackedObject> trackedObjects;
|
||||
private DatabaseDriver driver;
|
||||
private Date lastUpkeep;
|
||||
|
||||
public DatabaseManager()
|
||||
{
|
||||
@@ -27,6 +29,7 @@ public class DatabaseManager
|
||||
return;
|
||||
}
|
||||
|
||||
lastUpkeep = new Date();
|
||||
trackedObjects = new Vector<DatabaseTrackedObject>();
|
||||
driver = new DatabaseDriver();
|
||||
|
||||
@@ -57,6 +60,8 @@ public class DatabaseManager
|
||||
}
|
||||
}
|
||||
|
||||
lastUpkeep = new Date();
|
||||
|
||||
return numUpdated;
|
||||
}
|
||||
}
|
||||
@@ -85,4 +90,14 @@ public class DatabaseManager
|
||||
driver.CreateSetKey(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public Date GetLastUpkeep()
|
||||
{
|
||||
return lastUpkeep;
|
||||
}
|
||||
|
||||
public int GetTrackedObjectsSize()
|
||||
{
|
||||
return trackedObjects.size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,6 +336,7 @@ public class ObjectBuilderFactory
|
||||
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("dbflush"), new CommandDBFlush(KittyRole.Dev, KittyRating.Safe));
|
||||
manager.Register(LocCommands.Stub("dbstats"), new CommandDBStats(KittyRole.Dev, KittyRating.Safe));
|
||||
|
||||
// Admin
|
||||
manager.Register(LocCommands.Stub("rating"), new CommandRating(KittyRole.Admin, KittyRating.Safe));
|
||||
|
||||
Reference in New Issue
Block a user