mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
crawled date dependent on HttpStatusCode
This commit is contained in:
parent
7babb85b8c
commit
f437f7eef5
1 changed files with 11 additions and 8 deletions
|
|
@ -24,12 +24,13 @@ public async Task<IEnumerable<ListSummaryDto>> GetAllSummariesAsync()
|
|||
return summaries.GroupJoin(latestSnapshots, summary => summary.Id, snap => snap.FilterListId,
|
||||
(summary, snap) =>
|
||||
{
|
||||
var snaps = snap as Data.Entities.Snapshot[] ?? snap.ToArray();
|
||||
snap = snap as Data.Entities.Snapshot[] ?? snap.ToArray();
|
||||
var crawledDate = snap.Any() ? snap.Single().CreatedDateUtc : (DateTime?) null;
|
||||
return new ListSummaryDto
|
||||
{
|
||||
Id = summary.Id,
|
||||
AddedDate = summary.AddedDate,
|
||||
CrawledDate = snaps.Any() ? snaps.Single().CreatedDateUtc : (DateTime?) null,
|
||||
CrawledDate = crawledDate,
|
||||
Languages = summary.Languages,
|
||||
Name = summary.Name,
|
||||
ViewUrl = summary.ViewUrl
|
||||
|
|
@ -40,7 +41,7 @@ public async Task<IEnumerable<ListSummaryDto>> GetAllSummariesAsync()
|
|||
private async Task<List<ListSummaryDto>> GetSummaryDtos()
|
||||
{
|
||||
return await DbContext.FilterLists.AsNoTracking()
|
||||
.OrderBy(list => list.Name)
|
||||
.OrderBy(l => l.Name)
|
||||
.ProjectTo<ListSummaryDto>()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
|
@ -48,10 +49,10 @@ private async Task<List<ListSummaryDto>> GetSummaryDtos()
|
|||
private async Task<List<Data.Entities.Snapshot>> GetLatestSnapshots()
|
||||
{
|
||||
return await DbContext.Snapshots.AsNoTracking()
|
||||
.Where(snap =>
|
||||
snap.IsCompleted &&
|
||||
(snap.AddedSnapshotRules.Count > 0 || snap.RemovedSnapshotRules.Count > 0))
|
||||
.GroupBy(snap => snap.FilterListId,
|
||||
.Where(s => s.IsCompleted &&
|
||||
s.HttpStatusCode == "200" &&
|
||||
(s.AddedSnapshotRules.Count > 0 || s.RemovedSnapshotRules.Count > 0))
|
||||
.GroupBy(s => s.FilterListId,
|
||||
(key, x) => x.OrderByDescending(y => y.CreatedDateUtc).First())
|
||||
.ToListAsync();
|
||||
}
|
||||
|
|
@ -78,7 +79,9 @@ private async Task<int> GetActiveRuleCount(ListDetailsDto details)
|
|||
private async Task<DateTime?> GetCrawledDate(ListDetailsDto details)
|
||||
{
|
||||
var snapshotDates = DbContext.Snapshots.AsNoTracking()
|
||||
.Where(s => s.FilterListId == details.Id && s.IsCompleted &&
|
||||
.Where(s => s.FilterListId == details.Id &&
|
||||
s.IsCompleted &&
|
||||
s.HttpStatusCode == "200" &&
|
||||
(s.AddedSnapshotRules.Count > 0 ||
|
||||
s.RemovedSnapshotRules.Count > 0))
|
||||
.Select(s => s.CreatedDateUtc)
|
||||
|
|
|
|||
Loading…
Reference in a new issue