mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-07-16 08:01:01 +03:00
Compare commits
2 Commits
6ce0ef7d55
...
277e241183
Author | SHA1 | Date | |
---|---|---|---|
|
277e241183 | ||
|
3b41ea7b5f |
@ -5,7 +5,7 @@ using Avalonia.Data.Converters;
|
|||||||
namespace DHT.Desktop.Common {
|
namespace DHT.Desktop.Common {
|
||||||
sealed class NumberValueConverter : IValueConverter {
|
sealed class NumberValueConverter : IValueConverter {
|
||||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) {
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) {
|
||||||
return string.Format(Program.Culture, "{0:n0}", value);
|
return value == null ? "-" : string.Format(Program.Culture, "{0:n0}", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) {
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) {
|
||||||
|
@ -92,6 +92,8 @@ namespace DHT.Desktop.Main.Pages {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var oldStatistics = target.Statistics.Clone();
|
var oldStatistics = target.Statistics.Clone();
|
||||||
|
var oldMessageCount = target.CountMessages();
|
||||||
|
|
||||||
int successful = 0;
|
int successful = 0;
|
||||||
int finished = 0;
|
int finished = 0;
|
||||||
|
|
||||||
@ -132,7 +134,7 @@ namespace DHT.Desktop.Main.Pages {
|
|||||||
var newStatistics = target.Statistics;
|
var newStatistics = target.Statistics;
|
||||||
long newServers = newStatistics.TotalServers - oldStatistics.TotalServers;
|
long newServers = newStatistics.TotalServers - oldStatistics.TotalServers;
|
||||||
long newChannels = newStatistics.TotalChannels - oldStatistics.TotalChannels;
|
long newChannels = newStatistics.TotalChannels - oldStatistics.TotalChannels;
|
||||||
long newMessages = newStatistics.TotalMessages - oldStatistics.TotalMessages;
|
long newMessages = target.CountMessages() - oldMessageCount;
|
||||||
|
|
||||||
StringBuilder message = new StringBuilder();
|
StringBuilder message = new StringBuilder();
|
||||||
message.Append("Processed ");
|
message.Append("Processed ");
|
||||||
|
@ -35,7 +35,7 @@ namespace DHT.Desktop.Main.Pages {
|
|||||||
private readonly IDatabaseFile db;
|
private readonly IDatabaseFile db;
|
||||||
|
|
||||||
private bool isPageVisible = false;
|
private bool isPageVisible = false;
|
||||||
|
|
||||||
[Obsolete("Designer")]
|
[Obsolete("Designer")]
|
||||||
public ViewerPageModel() : this(null!, DummyDatabaseFile.Instance) {}
|
public ViewerPageModel() : this(null!, DummyDatabaseFile.Instance) {}
|
||||||
|
|
||||||
@ -46,7 +46,6 @@ namespace DHT.Desktop.Main.Pages {
|
|||||||
FilterModel = new FilterPanelModel(window, db);
|
FilterModel = new FilterPanelModel(window, db);
|
||||||
FilterModel.FilterPropertyChanged += OnFilterPropertyChanged;
|
FilterModel.FilterPropertyChanged += OnFilterPropertyChanged;
|
||||||
db.Statistics.PropertyChanged += OnDbStatisticsChanged;
|
db.Statistics.PropertyChanged += OnDbStatisticsChanged;
|
||||||
UpdateStatistics();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
@ -73,13 +72,17 @@ namespace DHT.Desktop.Main.Pages {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateStatistics() {
|
private void UpdateStatistics() {
|
||||||
ExportedMessageText = "Will export " + db.CountMessages(FilterModel.CreateFilter()).Format() + " out of " + db.Statistics.TotalMessages.Format() + " message(s).";
|
var filter = FilterModel.CreateFilter();
|
||||||
|
var allMessagesCount = db.Statistics.TotalMessages?.Format() ?? "?";
|
||||||
|
var filteredMessagesCount = filter.IsEmpty ? allMessagesCount : db.CountMessages(filter).Format();
|
||||||
|
|
||||||
|
ExportedMessageText = "Will export " + filteredMessagesCount + " out of " + allMessagesCount + " message(s).";
|
||||||
OnPropertyChanged(nameof(ExportedMessageText));
|
OnPropertyChanged(nameof(ExportedMessageText));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> GenerateViewerContents() {
|
private async Task<string> GenerateViewerContents() {
|
||||||
string json = ViewerJsonExport.Generate(db, FilterModel.CreateFilter());
|
string json = ViewerJsonExport.Generate(db, FilterModel.CreateFilter());
|
||||||
|
|
||||||
string index = await Resources.ReadTextAsync("Viewer/index.html");
|
string index = await Resources.ReadTextAsync("Viewer/index.html");
|
||||||
string viewer = index.Replace("/*[JS]*/", await Resources.ReadJoinedAsync("Viewer/scripts/", '\n'))
|
string viewer = index.Replace("/*[JS]*/", await Resources.ReadJoinedAsync("Viewer/scripts/", '\n'))
|
||||||
.Replace("/*[CSS]*/", await Resources.ReadJoinedAsync("Viewer/styles/", '\n'))
|
.Replace("/*[CSS]*/", await Resources.ReadJoinedAsync("Viewer/styles/", '\n'))
|
||||||
|
@ -3,11 +3,17 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace DHT.Server.Data.Filters {
|
namespace DHT.Server.Data.Filters {
|
||||||
public sealed class MessageFilter {
|
public sealed class MessageFilter {
|
||||||
public DateTime? StartDate { get; set; }
|
public DateTime? StartDate { get; set; } = null;
|
||||||
public DateTime? EndDate { get; set; }
|
public DateTime? EndDate { get; set; } = null;
|
||||||
|
|
||||||
public HashSet<ulong>? ChannelIds { get; set; } = null;
|
public HashSet<ulong>? ChannelIds { get; set; } = null;
|
||||||
public HashSet<ulong>? UserIds { get; set; } = null;
|
public HashSet<ulong>? UserIds { get; set; } = null;
|
||||||
public HashSet<ulong>? MessageIds { get; set; } = null;
|
public HashSet<ulong>? MessageIds { get; set; } = null;
|
||||||
|
|
||||||
|
public bool IsEmpty => StartDate == null &&
|
||||||
|
EndDate == null &&
|
||||||
|
ChannelIds == null &&
|
||||||
|
UserIds == null &&
|
||||||
|
MessageIds == null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ namespace DHT.Server.Database {
|
|||||||
private long totalServers;
|
private long totalServers;
|
||||||
private long totalChannels;
|
private long totalChannels;
|
||||||
private long totalUsers;
|
private long totalUsers;
|
||||||
private long totalMessages;
|
private long? totalMessages;
|
||||||
|
|
||||||
public long TotalServers {
|
public long TotalServers {
|
||||||
get => totalServers;
|
get => totalServers;
|
||||||
@ -22,7 +22,7 @@ namespace DHT.Server.Database {
|
|||||||
internal set => Change(ref totalUsers, value);
|
internal set => Change(ref totalUsers, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long TotalMessages {
|
public long? TotalMessages {
|
||||||
get => totalMessages;
|
get => totalMessages;
|
||||||
internal set => Change(ref totalMessages, value);
|
internal set => Change(ref totalMessages, value);
|
||||||
}
|
}
|
||||||
|
@ -46,11 +46,13 @@ namespace DHT.Server.Database.Sqlite {
|
|||||||
this.Path = path;
|
this.Path = path;
|
||||||
this.Statistics = new DatabaseStatistics();
|
this.Statistics = new DatabaseStatistics();
|
||||||
|
|
||||||
using var conn = pool.Take();
|
using (var conn = pool.Take()) {
|
||||||
UpdateServerStatistics(conn);
|
UpdateServerStatistics(conn);
|
||||||
UpdateChannelStatistics(conn);
|
UpdateChannelStatistics(conn);
|
||||||
UpdateUserStatistics(conn);
|
UpdateUserStatistics(conn);
|
||||||
UpdateMessageStatistics(conn);
|
}
|
||||||
|
|
||||||
|
messageStatisticsThread.RequestUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user