Skip to content

Commit

Permalink
add times played query
Browse files Browse the repository at this point in the history
  • Loading branch information
EmosewaMC committed Dec 10, 2024
1 parent e0b2a9c commit 490d548
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions dDatabase/GameDatabase/SQLite/SQLiteDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class SQLiteDatabase : public GameDatabase {
void UpdateScore(const uint32_t playerId, const uint32_t gameId, const Score& score) override;
std::optional<ILeaderboard::Score> GetPlayerScore(const uint32_t playerId, const uint32_t gameId) override;
void IncrementNumWins(const uint32_t playerId, const uint32_t gameId) override;
void IncrementTimesPlayed(const uint32_t playerId, const uint32_t gameId) override;
void InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<uint32_t> characterId) override;
void DeleteUgcBuild(const LWOOBJID bigId) override;
uint32_t GetAccountCount() override;
Expand Down
4 changes: 4 additions & 0 deletions dDatabase/GameDatabase/SQLite/Tables/Leaderboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,7 @@ std::optional<ILeaderboard::Score> SQLiteDatabase::GetPlayerScore(const uint32_t
void SQLiteDatabase::IncrementNumWins(const uint32_t playerId, const uint32_t gameId) {
ExecuteUpdate("UPDATE leaderboard SET numWins = numWins + 1, last_played = CURRENT_TIMESTAMP WHERE character_id = ? AND game_id = ?;", playerId, gameId);
}

void SQLiteDatabase::IncrementTimesPlayed(const uint32_t playerId, const uint32_t gameId) {
ExecuteUpdate("UPDATE leaderboard SET timesPlayed = timesPlayed + 1, last_played = CURRENT_TIMESTAMP WHERE character_id = ? AND game_id = ?;", playerId, gameId);
}

0 comments on commit 490d548

Please sign in to comment.