Fixed server and global ranking when the user didn't get any xp. close 1581
This commit is contained in:
		@@ -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;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user