Skip to content

Commit

Permalink
alternative performance fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
DeinFreund committed May 17, 2020
1 parent 95affe3 commit 9d8bf94
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Zero-K.info/Controllers/LobbyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ public async Task<ActionResult> 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))
{
Expand All @@ -203,9 +202,9 @@ 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);
model.Data = db.LobbyChatHistories
.Where(x => x.Target == model.Channel)
.OrderByDescending(x => x.LobbyChatHistoryID).Take(200).ToList().Where(x => x.SayPlace == SayPlace.Channel).AsQueryable();
}
else if (!string.IsNullOrEmpty(model.User))
{
Expand All @@ -224,7 +223,7 @@ await Global.Server.GhostSay(new Say()
});
}
//Users can abuse rename to gain access to other users PMs, it's a feature
ret = ret
model.Data = db.LobbyChatHistories
.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);
}
Expand All @@ -233,7 +232,6 @@ await Global.Server.GhostSay(new Say()
return PartialView("LobbyChatMessages", model);
}

model.Data = ret;
model.Message = "";

return PartialView("LobbyChatMessages", model);
Expand Down

0 comments on commit 9d8bf94

Please sign in to comment.