fix latest/earliest entry functions
This commit is contained in:
parent
4f339944c6
commit
20c44d41ca
@ -36,24 +36,28 @@ public class DiscordLogGenerator {
|
||||
return string.Format("EliteBGS {0}", ver);
|
||||
}
|
||||
|
||||
protected virtual DateTime GetDateOfEarliestEntry(Objective objective) {
|
||||
return objective
|
||||
protected virtual DateTime? GetDateOfEarliestEntry(Objective objective) {
|
||||
var it = objective
|
||||
.Transactions
|
||||
.SelectMany(x => x.Entries)
|
||||
.OrderBy(x => x.Timestamp)
|
||||
.First()
|
||||
.Timestamp
|
||||
.OrderBy(x => x.CompletedAtDateTime)
|
||||
.FirstOrDefault()
|
||||
;
|
||||
if (it != null) {
|
||||
return it.CompletedAtDateTime;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected virtual DateTime GetDateOfLatestEntry(Objective objective) {
|
||||
return objective
|
||||
protected virtual DateTime? GetDateOfLatestEntry(Objective objective) {
|
||||
var it = objective
|
||||
.Transactions
|
||||
.SelectMany(x => x.Entries)
|
||||
.OrderByDescending(x => x.Timestamp)
|
||||
.First()
|
||||
.Timestamp
|
||||
.OrderByDescending(x => x.CompletedAtDateTime)
|
||||
.FirstOrDefault()
|
||||
;
|
||||
if (it != null) {
|
||||
return it.CompletedAtDateTime;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected virtual string GenerateSummary(Objective objective) {
|
||||
@ -113,10 +117,14 @@ public class DiscordLogGenerator {
|
||||
DateTime.Now.ToString("dd/MM/yyyy"),
|
||||
GetToolVersion()
|
||||
);
|
||||
log.AppendFormat("**Date:** {0} - {1}\n",
|
||||
GetDateOfEarliestEntry(objective),
|
||||
GetDateOfLatestEntry(objective)
|
||||
);
|
||||
var earliest = GetDateOfEarliestEntry(objective);
|
||||
var latest = GetDateOfLatestEntry(objective);
|
||||
if (earliest != null && latest != null) {
|
||||
log.AppendFormat("**Date:** {0} - {1}\n",
|
||||
GetDateOfEarliestEntry(objective),
|
||||
GetDateOfLatestEntry(objective)
|
||||
);
|
||||
}
|
||||
log.AppendFormat("**Target:** {0}\n", location);
|
||||
if (!string.IsNullOrEmpty(summary)) {
|
||||
log.AppendFormat("**Summary**: {0}\n", summary);
|
||||
|
Loading…
Reference in New Issue
Block a user