Output date range in the export file

Closes #56
pull/70/head
Oleksii Holub 7 years ago
parent df811d0b1a
commit e4f0b8193f

@ -47,7 +47,7 @@ namespace DiscordChatExporter.Cli.ViewModels
var mentionables = await _dataService.GetMentionablesAsync(token, guild.Id, messages);
// Create log
var log = new ChatLog(guild, channel, messageGroups, mentionables);
var log = new ChatLog(guild, channel, from, to, messageGroups, mentionables);
// Export
_exportService.Export(format, filePath, log);

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
namespace DiscordChatExporter.Core.Models
@ -9,17 +10,23 @@ namespace DiscordChatExporter.Core.Models
public Channel Channel { get; }
public DateTime? From { get; }
public DateTime? To { get; }
public IReadOnlyList<MessageGroup> MessageGroups { get; }
public int TotalMessageCount => MessageGroups.Sum(g => g.Messages.Count);
public Mentionables Mentionables { get; }
public ChatLog(Guild guild, Channel channel, IReadOnlyList<MessageGroup> messageGroups,
Mentionables mentionables)
public ChatLog(Guild guild, Channel channel, DateTime? from, DateTime? to,
IReadOnlyList<MessageGroup> messageGroups, Mentionables mentionables)
{
Guild = guild;
Channel = channel;
From = from;
To = to;
MessageGroups = messageGroups;
Mentionables = mentionables;
}

@ -17,8 +17,24 @@
<div class="info__metadata">
<div class="info__guild-name">{{ Guild.Name | HtmlEncode }}</div>
<div class="info__channel-name">{{ Channel.Name | HtmlEncode }}</div>
<div class="info__channel-topic">{{ Channel.Topic | HtmlEncode }}</div>
{{ if Channel.Topic }}
<div class="info__channel-topic">{{ Channel.Topic | HtmlEncode }}</div>
{{ end }}
<div class="info__channel-message-count">{{ TotalMessageCount | Format "N0" }} messages</div>
{{ if From || To }}
<div class="info__channel-date-range">
{{ if From && To }}
Between {{ From | FormatDate }} and {{ To | FormatDate }}
{{ else if From }}
After {{ From | FormatDate }}
{{ else if To }}
Before {{ To | FormatDate }}
{{ end }}
</div>
{{ end }}
</div>
</div>

@ -65,8 +65,8 @@ img {
}
.info__guild-icon {
max-width: 64px;
max-height: 64px;
max-width: 88px;
max-height: 88px;
}
.info__metadata {
@ -90,6 +90,10 @@ img {
margin-top: 2px;
}
.info__channel-date-range {
margin-top: 2px;
}
/* === CHATLOG === */
.chatlog {

@ -3,6 +3,7 @@ Guild: {{ Guild.Name }}
Channel: {{ Channel.Name }}
Topic: {{ Channel.Topic }}
Messages: {{ TotalMessageCount | Format "N0" }}
Range: {{ if From }}{{ From | FormatDate }} {{ end }}{{ if From || To }}->{{ end }}{{ if To }} {{ To | FormatDate }}{{ end }}
==============================================================
{{~ for group in MessageGroups ~}}

@ -237,7 +237,7 @@ namespace DiscordChatExporter.Gui.ViewModels
var mentionables = await _dataService.GetMentionablesAsync(token, guild.Id, messages);
// Create log
var log = new ChatLog(guild, channel, messageGroups, mentionables);
var log = new ChatLog(guild, channel, from, to, messageGroups, mentionables);
// Export
_exportService.Export(format, filePath, log);

Loading…
Cancel
Save