From ab16600463f17e8d46c18b27cfd1436a5c026053 Mon Sep 17 00:00:00 2001 From: Adam R Grey Date: Sat, 29 Jun 2024 16:45:07 -0400 Subject: [PATCH] inerited channel stats works better before it would include 1 level, then assume that's the top. so 2 degrees of inheritance would confuse it --- .../Controllers/ChannelsController.cs | 16 ++++++- WebInterface/Views/Channels/Details.cshtml | 42 +++++++++++-------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/WebInterface/Controllers/ChannelsController.cs b/WebInterface/Controllers/ChannelsController.cs index 326376a..9a91891 100644 --- a/WebInterface/Controllers/ChannelsController.cs +++ b/WebInterface/Controllers/ChannelsController.cs @@ -27,7 +27,16 @@ public class ChannelsController : Controller { if(_db.Channels == null) return Problem("Entity set '_db.Channels' is null."); - var channel = await _db.Channels.Include(u => u.SubChannels).Include(u => u.Users).Include(u => u.ParentChannel).FirstAsync(u => u.Id == id); + //"but adam", says the strawman, "why load *every* channel and walk your way up? surely there's a .Load command that works or something." + //eh. I checked. Not really. You could make an SQL view that recurses its way up, meh idk how. You could just eagerly load *every* related object... + //but that would take in all the messages. + //realistically I expect this will have less than 1MB of total "channels", and several GB of total messages per (text) channel. + var AllChannels = await _db.Channels + .Include(u => u.SubChannels) + .Include(u => u.Users) + .Include(u => u.ParentChannel) + .ToListAsync(); + var channel = AllChannels.First(u => u.Id == id); var walker = channel; while(walker != null) { @@ -35,7 +44,10 @@ public class ChannelsController : Controller ViewData["breadcrumbs"]; walker = walker.ParentChannel; } - return View(channel); + return View( + new Tuple( + channel, channel.EffectivePermissions.LewdnessFilterLevel, channel.EffectivePermissions.MeannessFilterLevel + )); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] diff --git a/WebInterface/Views/Channels/Details.cshtml b/WebInterface/Views/Channels/Details.cshtml index 342ffb2..ab338a8 100644 --- a/WebInterface/Views/Channels/Details.cshtml +++ b/WebInterface/Views/Channels/Details.cshtml @@ -1,6 +1,12 @@ @using System.ComponentModel @using Newtonsoft.Json -@model Channel +@model Tuple +@{ + var ThisChannel = Model.Item1; + var IfInheritedLewdnessFilterLevel = Model.Item2; + var IfInheritedMeannessFilterLevel = Model.Item3; +} + @Html.Raw(ViewData["breadcrumbs"]) @@ -8,21 +14,21 @@ Display Name - @Model.DisplayName + @ThisChannel.DisplayName Channel type - @(Model.ChannelType != null ? Enumerations.GetDescription(Model.ChannelType) : "?") + @(ThisChannel.ChannelType != null ? Enumerations.GetDescription(ThisChannel.ChannelType) : "?") Lewdness Filter Level @@ -30,29 +36,29 @@ Links Allowed - @(Model.LinksAllowed?.ToString() ?? "unknown") + @(ThisChannel.LinksAllowed?.ToString() ?? "unknown") Lineage summary - @Model.LineageSummary + @ThisChannel.LineageSummary max attachment bytes - @Model.MaxAttachmentBytes (i hear there's "ByteSize") + @ThisChannel.MaxAttachmentBytes (i hear there's "ByteSize") max message length - @(Model.MaxTextChars?.ToString() ?? "inherited") + @(ThisChannel.MaxTextChars?.ToString() ?? "inherited") Meanness Filter Level @@ -60,23 +66,23 @@ Messages (count) - @(Model.Messages?.Count ?? 0) + @(ThisChannel.Messages?.Count ?? 0) Protocol - @Model.Protocol + @ThisChannel.Protocol Reactions Possible - @(Model.ReactionsPossible?.ToString() ?? "inherited") + @(ThisChannel.ReactionsPossible?.ToString() ?? "inherited") Sub Channels - @(Model.SubChannels?.Count ?? 0) + @(ThisChannel.SubChannels?.Count ?? 0) Users - @(Model.Users?.Count ?? 0) + @(ThisChannel.Users?.Count ?? 0) @@ -85,7 +91,7 @@ @section Scripts{