| 820 | } |
| 821 | |
| 822 | bool CScoreWorker::ShowRank(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize) |
| 823 | { |
| 824 | const auto *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData); |
| 825 | auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get()); |
| 826 | |
| 827 | char aServerLike[16]; |
| 828 | str_format(aServerLike, sizeof(aServerLike), "%%%s%%", pData->m_aServer); |
| 829 | |
| 830 | // check sort method |
| 831 | char aBuf[600]; |
| 832 | str_format(aBuf, sizeof(aBuf), |
| 833 | "SELECT Ranking, Time, PercentRank " |
| 834 | "FROM (" |
| 835 | " SELECT RANK() OVER w AS Ranking, PERCENT_RANK() OVER w as PercentRank, MIN(Time) AS Time, Name " |
| 836 | " FROM %s_race " |
| 837 | " WHERE Map = ? " |
| 838 | " AND Server LIKE ? " |
| 839 | " GROUP BY Name " |
| 840 | " WINDOW w AS (ORDER BY MIN(Time))" |
| 841 | ") as a " |
| 842 | "WHERE Name = ?", |
| 843 | pSqlServer->GetPrefix()); |
| 844 | |
| 845 | if(!pSqlServer->PrepareStatement(aBuf, pError, ErrorSize)) |
| 846 | { |
| 847 | return false; |
| 848 | } |
| 849 | pSqlServer->BindString(1, pData->m_aMap); |
| 850 | pSqlServer->BindString(2, aServerLike); |
| 851 | pSqlServer->BindString(3, pData->m_aName); |
| 852 | |
| 853 | bool End; |
| 854 | if(!pSqlServer->Step(&End, pError, ErrorSize)) |
| 855 | { |
| 856 | return false; |
| 857 | } |
| 858 | |
| 859 | char aRegionalRank[16]; |
| 860 | if(End) |
| 861 | { |
| 862 | str_copy(aRegionalRank, "unranked", sizeof(aRegionalRank)); |
| 863 | } |
| 864 | else |
| 865 | { |
| 866 | str_format(aRegionalRank, sizeof(aRegionalRank), "rank %d", pSqlServer->GetInt(1)); |
| 867 | } |
| 868 | |
| 869 | const char *pAny = "%"; |
| 870 | |
| 871 | if(!pSqlServer->PrepareStatement(aBuf, pError, ErrorSize)) |
| 872 | { |
| 873 | return false; |
| 874 | } |
| 875 | pSqlServer->BindString(1, pData->m_aMap); |
| 876 | pSqlServer->BindString(2, pAny); |
| 877 | pSqlServer->BindString(3, pData->m_aName); |
| 878 | |
| 879 | if(!pSqlServer->Step(&End, pError, ErrorSize)) |
nothing calls this directly
no test coverage detected