diff --git a/dGame/LeaderboardManager.cpp b/dGame/LeaderboardManager.cpp index dd890bd6..d9ba6a87 100644 --- a/dGame/LeaderboardManager.cpp +++ b/dGame/LeaderboardManager.cpp @@ -84,7 +84,7 @@ void Leaderboard::QueryToLdf(std::unique_ptr& rows) { entry.reserve(MAX_NUM_DATA_PER_ROW); entry.push_back(new LDFData(u"CharacterID", rows->getInt("character_id"))); entry.push_back(new LDFData(u"LastPlayed", rows->getUInt64("lastPlayed"))); - entry.push_back(new LDFData(u"NumPlayed", 1)); + entry.push_back(new LDFData(u"NumPlayed", rows->getInt("timesPlayed"))); entry.push_back(new LDFData(u"name", GeneralUtils::ASCIIToUTF16(rows->getString("name").c_str()))); entry.push_back(new LDFData(u"RowNumber", rows->getInt("ranking"))); switch (leaderboardType) { @@ -168,10 +168,11 @@ const std::string_view Leaderboard::GetOrdering(Leaderboard::Type leaderboardTyp void Leaderboard::SetupLeaderboard(uint32_t resultStart, uint32_t resultEnd) { resultStart++; resultEnd++; + // We need everything except 1 column so i'm selecting * from leaderboard const std::string queryBase = R"QUERY( WITH leaderboardsRanked AS ( - SELECT leaderboard.primaryScore, leaderboard.secondaryScore, leaderboard.tertiaryScore, charinfo.name, + SELECT leaderboard.*, charinfo.name, RANK() OVER ( ORDER BY %s, UNIX_TIMESTAMP(last_played) ASC, id DESC diff --git a/tests/dGameTests/LeaderboardTests.cpp b/tests/dGameTests/LeaderboardTests.cpp index b3480f51..b7946368 100644 --- a/tests/dGameTests/LeaderboardTests.cpp +++ b/tests/dGameTests/LeaderboardTests.cpp @@ -30,10 +30,10 @@ protected: Leaderboard leaderboard(gameID, infoType, false, 14231, type); leaderboard.SetupLeaderboard(); leaderboard.Serialize(&bitStream); - // TestLeaderboard(leaderboard, 1); - // TestLeaderboard(leaderboard, 10); - // TestLeaderboard(leaderboard, 100); - // TestLeaderboard(leaderboard, 1000); + TestLeaderboard(leaderboard, 1); + TestLeaderboard(leaderboard, 10); + TestLeaderboard(leaderboard, 100); + TestLeaderboard(leaderboard, 1000); } CBITSTREAM;