diff --git a/PluralKit.Bot/Commands/Lists/ContextListExt.cs b/PluralKit.Bot/Commands/Lists/ContextListExt.cs index 1b79dd39..6b043790 100644 --- a/PluralKit.Bot/Commands/Lists/ContextListExt.cs +++ b/PluralKit.Bot/Commands/Lists/ContextListExt.cs @@ -60,7 +60,8 @@ namespace PluralKit.Bot if (ctx.MatchFlag("with-last-switch", "with-last-fronted", "with-last-front", "wls", "wlf")) p.IncludeLastSwitch = true; if (ctx.MatchFlag("with-last-message", "with-last-proxy", "wlm", "wlp")) - p.IncludeLastMessage = true; + throw new PKError("Sorting by last message is temporarily disabled due to database issues, sorry."); + // p.IncludeLastMessage = true; if (ctx.MatchFlag("with-message-count", "wmc")) p.IncludeMessageCount = true; if (ctx.MatchFlag("with-created", "wc")) @@ -141,12 +142,12 @@ namespace PluralKit.Bot ret += $"(last switched in: )"; break; } - case SortProperty.LastMessage: - { - if (m.MetadataPrivacy.TryGet(lookupCtx, m.LastMessage, out var lastMsg)) - ret += $"(last message: )"; - break; - } + // case SortProperty.LastMessage: + // { + // if (m.MetadataPrivacy.TryGet(lookupCtx, m.LastMessage, out var lastMsg)) + // ret += $"(last message: )"; + // break; + // } case SortProperty.CreationDate: { if (m.MetadataPrivacy.TryGet(lookupCtx, m.Created, out var created)) @@ -159,8 +160,8 @@ namespace PluralKit.Bot ret += $"({count} messages)"; else if (opts.IncludeLastSwitch && m.MetadataPrivacy.TryGet(lookupCtx, m.LastSwitchTime, out var lastSw)) ret += $"(last switched in: )"; - else if (opts.IncludeLastMessage && m.MetadataPrivacy.TryGet(lookupCtx, m.LastMessage, out var lastMsg)) - ret += $"(last message: )"; + // else if (opts.IncludeLastMessage && m.MetadataPrivacy.TryGet(lookupCtx, m.LastMessage, out var lastMsg)) + // ret += $"(last message: )"; else if (opts.IncludeCreated && m.MetadataPrivacy.TryGet(lookupCtx, m.Created, out var created)) ret += $"(created at )"; else if (opts.IncludeAvatar && m.AvatarFor(lookupCtx) is { } avatarUrl) @@ -203,8 +204,8 @@ namespace PluralKit.Bot if ((opts.IncludeMessageCount || opts.SortProperty == SortProperty.MessageCount) && m.MessageCountFor(lookupCtx) is { } count && count > 0) profile.Append($"\n**Message count:** {count}"); - if ((opts.IncludeLastMessage || opts.SortProperty == SortProperty.LastMessage) && m.MetadataPrivacy.TryGet(lookupCtx, m.LastMessage, out var lastMsg)) - profile.Append($"\n**Last message:** {DiscordUtils.SnowflakeToInstant(lastMsg.Value).FormatZoned(zone)}"); + // if ((opts.IncludeLastMessage || opts.SortProperty == SortProperty.LastMessage) && m.MetadataPrivacy.TryGet(lookupCtx, m.LastMessage, out var lastMsg)) + // profile.Append($"\n**Last message:** {DiscordUtils.SnowflakeToInstant(lastMsg.Value).FormatZoned(zone)}"); if ((opts.IncludeLastSwitch || opts.SortProperty == SortProperty.LastSwitch) && m.MetadataPrivacy.TryGet(lookupCtx, m.LastSwitchTime, out var lastSw)) profile.Append($"\n**Last switched in:** {lastSw.Value.FormatZoned(zone)}"); diff --git a/PluralKit.Bot/Commands/Lists/MemberListOptions.cs b/PluralKit.Bot/Commands/Lists/MemberListOptions.cs index e77aece6..d0970885 100644 --- a/PluralKit.Bot/Commands/Lists/MemberListOptions.cs +++ b/PluralKit.Bot/Commands/Lists/MemberListOptions.cs @@ -98,9 +98,10 @@ namespace PluralKit.Bot SortProperty.Birthdate => input .OrderByDescending(m => m.AnnualBirthday.HasValue) .ThenBy(m => m.AnnualBirthday, ReverseMaybe(Comparer.Default)), - SortProperty.LastMessage => input - .OrderByDescending(m => m.LastMessage.HasValue) - .ThenByDescending(m => m.LastMessage, ReverseMaybe(Comparer.Default)), + SortProperty.LastMessage => throw new PKError("Sorting by last message is temporarily disabled due to database issues, sorry."), + // SortProperty.LastMessage => input + // .OrderByDescending(m => m.LastMessage.HasValue) + // .ThenByDescending(m => m.LastMessage, ReverseMaybe(Comparer.Default)), SortProperty.LastSwitch => input .OrderByDescending(m => m.LastSwitchTime.HasValue) .ThenByDescending(m => m.LastSwitchTime, ReverseMaybe(Comparer.Default)), diff --git a/PluralKit.Core/Database/Views/ListedMember.cs b/PluralKit.Core/Database/Views/ListedMember.cs index 3d1646b6..560474ee 100644 --- a/PluralKit.Core/Database/Views/ListedMember.cs +++ b/PluralKit.Core/Database/Views/ListedMember.cs @@ -6,7 +6,7 @@ namespace PluralKit.Core // TODO: is inheritance here correct? public class ListedMember: PKMember { - public ulong? LastMessage { get; } + // public ulong? LastMessage { get; } public Instant? LastSwitchTime { get; } public AnnualDate? AnnualBirthday => diff --git a/PluralKit.Core/Database/Views/views.sql b/PluralKit.Core/Database/Views/views.sql index 5fd1784b..310ec9fb 100644 --- a/PluralKit.Core/Database/Views/views.sql +++ b/PluralKit.Core/Database/Views/views.sql @@ -30,7 +30,7 @@ create view member_list as select members.*, -- Find last message ID -- max(mid) does full table scan, order by/limit uses index (dunno why, but it works!) - (select mid from messages where messages.member = members.id order by mid desc nulls last limit 1) as last_message, + -- (select mid from messages where messages.member = members.id order by mid desc nulls last limit 1) as last_message, -- Find last switch timestamp (