From ae7d53629ff48685c3c09bca48c41b154c2cc130 Mon Sep 17 00:00:00 2001 From: DeinFreund Date: Sun, 17 May 2020 18:28:34 +0200 Subject: [PATCH] alternative performance fix? --- Zero-K.info/Controllers/LobbyController.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Zero-K.info/Controllers/LobbyController.cs b/Zero-K.info/Controllers/LobbyController.cs index 34f35aaec7..033b14e16d 100644 --- a/Zero-K.info/Controllers/LobbyController.cs +++ b/Zero-K.info/Controllers/LobbyController.cs @@ -183,7 +183,6 @@ public async Task ChatMessages(ChatModel model) model = model ?? new ChatModel(); var db = new ZkDataContext(); - var ret = db.LobbyChatHistories.AsQueryable(); bool isMuted = Punishment.GetActivePunishment(Global.AccountID, Request.UserHostAddress, 0, null, x => x.BanMute) != null; if (!string.IsNullOrEmpty(model.Channel)) { @@ -203,9 +202,10 @@ await Global.Server.GhostSay(new Say() User = Global.Account.Name, }); } - ret = ret - .Where(x => x.Target == model.Channel && x.SayPlace == SayPlace.Channel) - .OrderByDescending(x => x.LobbyChatHistoryID).Take(200); + string channelName = model.Channel; + model.Data = db.LobbyChatHistories + .Where(x => channelName == x.Target && x.SayPlace == SayPlace.Channel) + .OrderByDescending(x => x.Time); } else if (!string.IsNullOrEmpty(model.User)) { @@ -223,17 +223,18 @@ await Global.Server.GhostSay(new Say() User = Global.Account.Name, }); } + string otherName = model.User; + string myName = Global.Account.Name; //Users can abuse rename to gain access to other users PMs, it's a feature - ret = ret - .Where(x => (x.User == model.User && x.Target == Global.Account.Name || x.User == Global.Account.Name && x.Target == model.User) && x.SayPlace == SayPlace.User) - .OrderByDescending(x => x.LobbyChatHistoryID); + model.Data = db.LobbyChatHistories + .Where(x => (x.User == otherName && x.Target == myName || x.User == myName && x.Target == otherName) && x.SayPlace == SayPlace.User) + .OrderByDescending(x => x.Time); } else { return PartialView("LobbyChatMessages", model); } - model.Data = ret; model.Message = ""; return PartialView("LobbyChatMessages", model);