Просмотр исходного кода

Track last login time for accounts

Ivan Savenko 1 год назад
Родитель
Сommit
77f177adc7
2 измененных файлов с 9 добавлено и 2 удалено
  1. 8 1
      lobby/LobbyDatabase.cpp
  2. 1 1
      lobby/LobbyDatabase.h

+ 8 - 1
lobby/LobbyDatabase.cpp

@@ -149,6 +149,12 @@ void LobbyDatabase::prepareStatements()
 		WHERE roomID = ?
 	)";
 
+	static const std::string updateAccountLoginTimeText = R"(
+		UPDATE accounts
+		SET lastLoginTime = CURRENT_TIMESTAMP
+		WHERE accountID = ?
+	)";
+
 	// SELECT FROM
 
 	static const std::string getRecentMessageHistoryText = R"(
@@ -263,6 +269,7 @@ void LobbyDatabase::prepareStatements()
 
 	setAccountOnlineStatement = database->prepare(setAccountOnlineText);
 	setGameRoomStatusStatement = database->prepare(setGameRoomStatusText);
+	updateAccountLoginTimeStatement = database->prepare(updateAccountLoginTimeText);
 
 	getRecentMessageHistoryStatement = database->prepare(getRecentMessageHistoryText);
 	getIdleGameRoomStatement = database->prepare(getIdleGameRoomText);
@@ -382,7 +389,7 @@ void LobbyDatabase::insertAccessCookie(const std::string & accountID, const std:
 
 void LobbyDatabase::updateAccountLoginTime(const std::string & accountID)
 {
-	assert(0);
+	updateAccountLoginTimeStatement->executeOnce(accountID);
 }
 
 std::string LobbyDatabase::getAccountDisplayName(const std::string & accountID)

+ 1 - 1
lobby/LobbyDatabase.h

@@ -33,7 +33,7 @@ class LobbyDatabase
 
 	SQLiteStatementPtr setAccountOnlineStatement;
 	SQLiteStatementPtr setGameRoomStatusStatement;
-	SQLiteStatementPtr setGameRoomPlayerLimitStatement;
+	SQLiteStatementPtr updateAccountLoginTimeStatement;
 
 	SQLiteStatementPtr getRecentMessageHistoryStatement;
 	SQLiteStatementPtr getIdleGameRoomStatement;