Fixed server and global ranking when the user didn't get any xp. close 1581

This commit is contained in:
Master Kwoth 2017-09-23 12:28:13 +02:00
parent 851452f950
commit 2d8b9d677c
3 changed files with 9 additions and 3 deletions

View File

@ -99,7 +99,6 @@ namespace NadekoBot.Modules.Searches.Common
public async Task<ImageCacherObject[]> DownloadImages(string tag, bool isExplicit, DapiSearchType type) public async Task<ImageCacherObject[]> DownloadImages(string tag, bool isExplicit, DapiSearchType type)
{ {
_log.Info($"Loading extra images from {type}");
tag = tag?.Replace(" ", "_").ToLowerInvariant(); tag = tag?.Replace(" ", "_").ToLowerInvariant();
if (isExplicit) if (isExplicit)
tag = "rating%3Aexplicit+" + tag; tag = "rating%3Aexplicit+" + tag;

View File

@ -40,10 +40,14 @@ namespace NadekoBot.Services.Database.Repositories.Impl
public int GetUserGlobalRanking(ulong id) public int GetUserGlobalRanking(ulong id)
{ {
return _set.Count(x => x.TotalXp > if (!_set.Where(y => y.UserId == id).Any())
{
return _set.Count();
}
return _set.Count(x => x.TotalXp >=
_set.Where(y => y.UserId == id) _set.Where(y => y.UserId == id)
.DefaultIfEmpty() .DefaultIfEmpty()
.Sum(y => y.TotalXp)); .Sum(y => y.TotalXp)) + 1;
} }
public DiscordUser[] GetUsersXpLeaderboardFor(int page) public DiscordUser[] GetUsersXpLeaderboardFor(int page)

View File

@ -39,6 +39,9 @@ namespace NadekoBot.Services.Database.Repositories.Impl
public int GetUserGuildRanking(ulong userId, ulong guildId) public int GetUserGuildRanking(ulong userId, ulong guildId)
{ {
if (!_set.Where(x => x.GuildId == guildId && x.UserId == userId).Any())
return _set.Count();
return _set return _set
.Where(x => x.GuildId == guildId) .Where(x => x.GuildId == guildId)
.Count(x => x.Xp > (_set .Count(x => x.Xp > (_set