mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
fix null updated date
This commit is contained in:
parent
74eabf7db4
commit
aaee3326e4
3 changed files with 26 additions and 25 deletions
|
|
@ -21,15 +21,19 @@ public async Task<IEnumerable<ListSummaryDto>> GetAllSummariesAsync()
|
|||
{
|
||||
var summaries = await GetSummaryDtos();
|
||||
var latestUpdatedSnapshots = await GetLatestUpdatedSnapshots();
|
||||
return summaries.Join(latestUpdatedSnapshots, summary => summary.Id, snap => snap.FilterListId,
|
||||
(summary, snap) => new ListSummaryDto
|
||||
return summaries.GroupJoin(latestUpdatedSnapshots, summary => summary.Id, snap => snap.FilterListId,
|
||||
(summary, snap) =>
|
||||
{
|
||||
Id = summary.Id,
|
||||
AddedDate = summary.AddedDate,
|
||||
Languages = summary.Languages,
|
||||
Name = summary.Name,
|
||||
UpdatedDate = snap.CreatedDateUtc,
|
||||
ViewUrl = summary.ViewUrl
|
||||
var snaps = snap as Data.Entities.Snapshot[] ?? snap.ToArray();
|
||||
return new ListSummaryDto
|
||||
{
|
||||
Id = summary.Id,
|
||||
AddedDate = summary.AddedDate,
|
||||
Languages = summary.Languages,
|
||||
Name = summary.Name,
|
||||
UpdatedDate = snaps.Any() ? snaps.Single().CreatedDateUtc : (DateTime?) null,
|
||||
ViewUrl = summary.ViewUrl
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -65,24 +69,21 @@ public async Task<ListDetailsDto> GetDetailsAsync(int id)
|
|||
|
||||
private async Task<int> GetActiveRuleCount(ListDetailsDto details)
|
||||
{
|
||||
return await DbContext.Snapshots.AsNoTracking()
|
||||
.Where(s => s.FilterListId == details.Id && s.IsCompleted)
|
||||
.SelectMany(sr => sr.AddedSnapshotRules)
|
||||
.CountAsync() -
|
||||
await DbContext.Snapshots.AsNoTracking()
|
||||
.Where(s => s.FilterListId == details.Id && s.IsCompleted)
|
||||
.SelectMany(sr => sr.RemovedSnapshotRules)
|
||||
.CountAsync();
|
||||
var listSnapshots = DbContext.Snapshots.AsNoTracking()
|
||||
.Where(s => s.FilterListId == details.Id && s.IsCompleted);
|
||||
return await listSnapshots.SelectMany(sr => sr.AddedSnapshotRules).CountAsync() -
|
||||
await listSnapshots.SelectMany(sr => sr.RemovedSnapshotRules).CountAsync();
|
||||
}
|
||||
|
||||
private async Task<DateTime> GetUpdatedDate(ListDetailsDto details)
|
||||
private async Task<DateTime?> GetUpdatedDate(ListDetailsDto details)
|
||||
{
|
||||
return await DbContext.Snapshots.AsNoTracking()
|
||||
.Where(s => s.FilterListId == details.Id && s.IsCompleted &&
|
||||
(s.AddedSnapshotRules.Count > 0 || s.RemovedSnapshotRules.Count > 0))
|
||||
.Select(s => s.CreatedDateUtc)
|
||||
.OrderByDescending(s => s.Date)
|
||||
.FirstAsync();
|
||||
var snapshotDates = DbContext.Snapshots.AsNoTracking()
|
||||
.Where(s => s.FilterListId == details.Id && s.IsCompleted &&
|
||||
(s.AddedSnapshotRules.Count > 0 ||
|
||||
s.RemovedSnapshotRules.Count > 0))
|
||||
.Select(s => s.CreatedDateUtc)
|
||||
.OrderByDescending(s => s.Date);
|
||||
return snapshotDates.Any() ? (DateTime?) await snapshotDates.FirstAsync() : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ public class ListDetailsDto
|
|||
public int RuleCount { get; set; }
|
||||
public string SubmissionUrl { get; set; }
|
||||
public ListSyntaxDto Syntax { get; set; }
|
||||
public DateTime UpdatedDate { get; set; }
|
||||
public DateTime? UpdatedDate { get; set; }
|
||||
public string ViewUrl { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ public class ListSummaryDto
|
|||
public DateTime AddedDate { get; set; }
|
||||
public IEnumerable<ListLanguagesDto> Languages { get; set; }
|
||||
public string Name { get; set; }
|
||||
public DateTime UpdatedDate { get; set; }
|
||||
public DateTime? UpdatedDate { get; set; }
|
||||
public string ViewUrl { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue