mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 03:53:26 -08:00
[Server] Record uptime through the database interface (#7856)
This commit is contained in:
parent
f1ee6bdc2d
commit
09d0bed997
4 changed files with 49 additions and 13 deletions
|
|
@ -879,19 +879,16 @@ void Servatrice::statusUpdate()
|
|||
rxBytes = 0;
|
||||
rxBytesMutex.unlock();
|
||||
|
||||
QSqlQuery *query = servatriceDatabaseInterface->prepareQuery(
|
||||
"insert into {prefix}_uptime (id_server, timest, uptime, users_count, mods_count, mods_list, games_count, "
|
||||
"tx_bytes, rx_bytes) values(:id, NOW(), :uptime, :users_count, :mods_count, :mods_list, :games_count, :tx, "
|
||||
":rx)");
|
||||
query->bindValue(":id", serverId);
|
||||
query->bindValue(":uptime", uptime);
|
||||
query->bindValue(":users_count", uc);
|
||||
query->bindValue(":mods_count", mc);
|
||||
query->bindValue(":mods_list", ml);
|
||||
query->bindValue(":games_count", gc);
|
||||
query->bindValue(":tx", tx);
|
||||
query->bindValue(":rx", rx);
|
||||
servatriceDatabaseInterface->execSqlQuery(query);
|
||||
Server_DatabaseInterface::UptimeRecord uptimeRecord;
|
||||
uptimeRecord.serverId = serverId;
|
||||
uptimeRecord.uptimeSecs = uptime;
|
||||
uptimeRecord.usersCount = uc;
|
||||
uptimeRecord.modsCount = mc;
|
||||
uptimeRecord.modsList = ml;
|
||||
uptimeRecord.gamesCount = gc;
|
||||
uptimeRecord.txBytes = tx;
|
||||
uptimeRecord.rxBytes = rx;
|
||||
servatriceDatabaseInterface->recordUptime(uptimeRecord);
|
||||
|
||||
if (getRegistrationEnabled() && getEnableInternalSMTPClient()) {
|
||||
if (getRequireEmailActivationEnabled()) {
|
||||
|
|
|
|||
|
|
@ -3337,6 +3337,27 @@ QList<Server_DatabaseInterface::ServerListEntryRecord> Servatrice_DatabaseInterf
|
|||
return entries;
|
||||
}
|
||||
|
||||
void Servatrice_DatabaseInterface::recordUptime(const UptimeRecord &record)
|
||||
{
|
||||
if (!checkSql()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QSqlQuery *query = prepareQuery(
|
||||
"insert into {prefix}_uptime (id_server, timest, uptime, users_count, mods_count, mods_list, games_count, "
|
||||
"tx_bytes, rx_bytes) values(:id, NOW(), :uptime, :users_count, :mods_count, :mods_list, :games_count, :tx, "
|
||||
":rx)");
|
||||
query->bindValue(":id", record.serverId);
|
||||
query->bindValue(":uptime", record.uptimeSecs);
|
||||
query->bindValue(":users_count", record.usersCount);
|
||||
query->bindValue(":mods_count", record.modsCount);
|
||||
query->bindValue(":mods_list", record.modsList);
|
||||
query->bindValue(":games_count", record.gamesCount);
|
||||
query->bindValue(":tx", record.txBytes);
|
||||
query->bindValue(":rx", record.rxBytes);
|
||||
execSqlQuery(query);
|
||||
}
|
||||
|
||||
bool Servatrice_DatabaseInterface::removeUserAvatar(const QString &userName)
|
||||
{
|
||||
if (!checkSql()) {
|
||||
|
|
|
|||
|
|
@ -280,6 +280,7 @@ public:
|
|||
UptimeSnapshot getLatestUptimeSnapshot(int serverId) override;
|
||||
bool getLatestServerMessage(int serverId, QString &message) override;
|
||||
QList<ServerListEntryRecord> getServerListEntries() override;
|
||||
void recordUptime(const UptimeRecord &record) override;
|
||||
bool removeUserAvatar(const QString &userName) override;
|
||||
// Outcome of removeUserBanner(), so the caller can tell a missing user apart
|
||||
// from a user who simply has no banner card set.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue