From 2e083bc188b9eb78365e4afe1e4ec996ea0f9b4a Mon Sep 17 00:00:00 2001 From: Runebaas Date: Wed, 25 Oct 2017 19:33:22 +0200 Subject: [PATCH] Fixing the highscore bug (hopefully) --- Geekbot.net/Lib/UserRepository.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Geekbot.net/Lib/UserRepository.cs b/Geekbot.net/Lib/UserRepository.cs index 4832aac..4f5de16 100644 --- a/Geekbot.net/Lib/UserRepository.cs +++ b/Geekbot.net/Lib/UserRepository.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using AngleSharp.Dom.Css; using Discord.WebSocket; using Serilog; using StackExchange.Redis; @@ -20,13 +21,14 @@ namespace Geekbot.net.Lib { try { - _redis.HashSetAsync($"Users:{user.Id}", new HashEntry[] + _redis.HashSetAsync($"Users:{user.Id.ToString()}", new HashEntry[] { new HashEntry("Id", user.Id.ToString()), new HashEntry("Username", user.Username), new HashEntry("Discriminator", user.Discriminator), new HashEntry("AvatarUrl", user.GetAvatarUrl() ?? "0"), new HashEntry("IsBot", user.IsBot), + new HashEntry("Joined", user.CreatedAt.ToString()), }); _logger.Information($"[UserRepository] Updated User {user.Id}"); return Task.FromResult(true); @@ -40,11 +42,11 @@ namespace Geekbot.net.Lib public UserRepositoryUser Get(ulong userId) { - var user = _redis.HashGetAll($"Users:{userId}"); - for (int i = 1; i < 6; i++) + var user = _redis.HashGetAll($"Users:{userId.ToString()}"); + for (int i = 1; i < 11; i++) { if (user.Length != 0) break; - user = _redis.HashGetAll($"Users:{userId + (ulong)i}"); + user = _redis.HashGetAll($"Users:{(userId + (ulong)i).ToString()}"); } var dto = new UserRepositoryUser(); @@ -67,6 +69,9 @@ namespace Geekbot.net.Lib case "IsBot": dto.IsBot = a.Value == 1; break; + case "Joined": + dto.Joined = DateTimeOffset.Parse(a.Value); + break; } } return dto; @@ -94,6 +99,7 @@ namespace Geekbot.net.Lib public string Discriminator { get; set; } public string AvatarUrl { get; set; } public bool IsBot { get; set; } + public DateTimeOffset Joined { get; set; } } public interface IUserRepository