diff --git a/libcockatrice_network/libcockatrice/network/server/remote/server_database_interface.h b/libcockatrice_network/libcockatrice/network/server/remote/server_database_interface.h index e93318e8f..ad9106a6e 100644 --- a/libcockatrice_network/libcockatrice/network/server/remote/server_database_interface.h +++ b/libcockatrice_network/libcockatrice/network/server/remote/server_database_interface.h @@ -425,6 +425,24 @@ public: virtual int getNextReplayId() = 0; virtual int getActiveUserCount(QString connectionType = QString()) = 0; + /** @brief Snapshot recorded by the server's periodic status update into the uptime table. */ + struct UptimeSnapshot + { + bool valid = false; + quint64 usersCount = 0; + quint64 modsCount = 0; + quint64 gamesCount = 0; + quint64 txBytes = 0; + quint64 rxBytes = 0; + quint64 uptimeSecs = 0; + quint64 timest = 0; + }; + /** @brief Freshest uptime snapshot of one server; an invalid snapshot when none exists. */ + virtual UptimeSnapshot getLatestUptimeSnapshot(int /* serverId */) + { + return {}; + } + virtual void clearSessionTables() { } diff --git a/servatrice/src/servatrice_database_interface.cpp b/servatrice/src/servatrice_database_interface.cpp index 89a586298..a777a23a9 100644 --- a/servatrice/src/servatrice_database_interface.cpp +++ b/servatrice/src/servatrice_database_interface.cpp @@ -3008,7 +3008,7 @@ QList Servatrice_DatabaseInterface::getModeratorLastL return results; } -Servatrice_DatabaseInterface::UptimeSnapshot Servatrice_DatabaseInterface::getLatestUptimeSnapshot(int serverId) +Server_DatabaseInterface::UptimeSnapshot Servatrice_DatabaseInterface::getLatestUptimeSnapshot(int serverId) { UptimeSnapshot snapshot; diff --git a/servatrice/src/servatrice_database_interface.h b/servatrice/src/servatrice_database_interface.h index 802a4022b..4e18882c7 100644 --- a/servatrice/src/servatrice_database_interface.h +++ b/servatrice/src/servatrice_database_interface.h @@ -257,18 +257,7 @@ public: // Uptime snapshot as recorded by Servatrice::statusUpdate() into the // {prefix}_uptime table. valid is false when no snapshot exists yet. - struct UptimeSnapshot - { - bool valid = false; - quint64 usersCount = 0; - quint64 modsCount = 0; - quint64 gamesCount = 0; - quint64 txBytes = 0; - quint64 rxBytes = 0; - quint64 uptimeSecs = 0; - quint64 timest = 0; - }; - UptimeSnapshot getLatestUptimeSnapshot(int serverId); + UptimeSnapshot getLatestUptimeSnapshot(int serverId) override; bool removeUserAvatar(const QString &userName); // Outcome of removeUserBanner(), so the caller can tell a missing user apart diff --git a/servatrice/src/serversocketinterface.cpp b/servatrice/src/serversocketinterface.cpp index c73f08e5a..d1b043f10 100644 --- a/servatrice/src/serversocketinterface.cpp +++ b/servatrice/src/serversocketinterface.cpp @@ -2186,13 +2186,13 @@ Response::ResponseCode AbstractServerSocketInterface::cmdReportUserInfo(const Co Response::ResponseCode AbstractServerSocketInterface::cmdGetServerStats(const Command_GetServerStats & /*cmd */, ResponseContainer &rc) { - if (!sqlInterface->checkSql()) { + if (!databaseInterface->checkSql()) { return Response::RespInternalError; } // Servatrice::statusUpdate() periodically snapshots server health into the // uptime table. Serve the freshest snapshot for this server. - const auto snapshot = sqlInterface->getLatestUptimeSnapshot(servatrice->getServerID()); + const auto snapshot = databaseInterface->getLatestUptimeSnapshot(servatrice->getServerID()); if (!snapshot.valid) { // No snapshot yet (fresh server, or statusUpdate() has not ticked). return Response::RespInternalError;