From bcad5b4ed137e53d5aab9c3ea7993a8fbd6a550f Mon Sep 17 00:00:00 2001 From: Oleksii Holub Date: Wed, 31 Oct 2018 17:34:57 +0200 Subject: [PATCH] Set ChatLog.TotalMessageCount from ChatLogService --- DiscordChatExporter.Core/Models/ChatLog.cs | 5 +++-- DiscordChatExporter.Core/Services/ChatLogService.cs | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/DiscordChatExporter.Core/Models/ChatLog.cs b/DiscordChatExporter.Core/Models/ChatLog.cs index a5c38f0..aa8c476 100644 --- a/DiscordChatExporter.Core/Models/ChatLog.cs +++ b/DiscordChatExporter.Core/Models/ChatLog.cs @@ -16,18 +16,19 @@ namespace DiscordChatExporter.Core.Models public IReadOnlyList MessageGroups { get; } - public int TotalMessageCount => MessageGroups.Sum(g => g.Messages.Count); + public long TotalMessageCount { get; } public Mentionables Mentionables { get; } public ChatLog(Guild guild, Channel channel, DateTime? from, DateTime? to, - IReadOnlyList messageGroups, Mentionables mentionables) + IReadOnlyList messageGroups, long totalMessageCount, Mentionables mentionables) { Guild = guild; Channel = channel; From = from; To = to; MessageGroups = messageGroups; + TotalMessageCount = totalMessageCount; Mentionables = mentionables; } diff --git a/DiscordChatExporter.Core/Services/ChatLogService.cs b/DiscordChatExporter.Core/Services/ChatLogService.cs index 5592847..2bd4695 100644 --- a/DiscordChatExporter.Core/Services/ChatLogService.cs +++ b/DiscordChatExporter.Core/Services/ChatLogService.cs @@ -24,10 +24,13 @@ namespace DiscordChatExporter.Core.Services // Group messages var messageGroups = _messageGroupService.GroupMessages(messages); + // Get total message count + var totalMessageCount = messages.Count; + // Get mentionables var mentionables = await _dataService.GetMentionablesAsync(token, guild.Id, messages); - return new ChatLog(guild, channel, from, to, messageGroups, mentionables); + return new ChatLog(guild, channel, from, to, messageGroups, totalMessageCount, mentionables); } public async Task GetChatLogAsync(AuthToken token, string channelId,