mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
revert extracting Func<>s
despite trying many forms, the AsQueryable() (see [here](https://stackoverflow.com/a/51812063/2343739)) generates broken mysql code
This commit is contained in:
parent
bd3523d4d6
commit
4e83f9c779
2 changed files with 10 additions and 18 deletions
|
|
@ -9,12 +9,6 @@ namespace FilterLists.Services.FilterList.MappingProfiles
|
|||
[UsedImplicitly]
|
||||
public class ListDetailsDtoMappingProfile : Profile
|
||||
{
|
||||
private readonly Func<Data.Entities.Snapshot, bool> isDiffSnapshot =
|
||||
s => s.AddedSnapshotRules.Count > 0 || s.RemovedSnapshotRules.Count > 0;
|
||||
|
||||
private readonly Func<Data.Entities.Snapshot, bool> isSuccessfulSnapshot =
|
||||
s => s.IsCompleted && s.HttpStatusCode == "200";
|
||||
|
||||
public ListDetailsDtoMappingProfile() =>
|
||||
CreateMap<Data.Entities.FilterList, ListDetailsDto>()
|
||||
.ForMember(d => d.AddedDate, c => c.MapFrom(l => l.CreatedDateUtc))
|
||||
|
|
@ -22,12 +16,16 @@ public ListDetailsDtoMappingProfile() =>
|
|||
.ForMember(d => d.Maintainers, c => c.MapFrom(l => l.FilterListMaintainers.Select(m => m.Maintainer)))
|
||||
.ForMember(d => d.RuleCount,
|
||||
c => c.MapFrom(l =>
|
||||
l.Snapshots.Where(isSuccessfulSnapshot).SelectMany(sr => sr.AddedSnapshotRules).Count() -
|
||||
l.Snapshots.Where(isSuccessfulSnapshot).SelectMany(sr => sr.RemovedSnapshotRules).Count()))
|
||||
l.Snapshots.Where(s => s.IsCompleted && s.HttpStatusCode == "200")
|
||||
.SelectMany(sr => sr.AddedSnapshotRules)
|
||||
.Count() -
|
||||
l.Snapshots.Where(s => s.IsCompleted && s.HttpStatusCode == "200")
|
||||
.SelectMany(sr => sr.RemovedSnapshotRules)
|
||||
.Count()))
|
||||
.ForMember(d => d.UpdatedDate,
|
||||
c => c.MapFrom(l =>
|
||||
l.Snapshots.Where(isSuccessfulSnapshot)
|
||||
.Where(isDiffSnapshot)
|
||||
l.Snapshots.Where(s => s.IsCompleted && s.HttpStatusCode == "200")
|
||||
.Where(s => s.AddedSnapshotRules.Count > 0 || s.RemovedSnapshotRules.Count > 0)
|
||||
.OrderByDescending(s => s.CreatedDateUtc)
|
||||
.Select(s => s.CreatedDateUtc)
|
||||
.Cast<DateTime?>()
|
||||
|
|
|
|||
|
|
@ -9,20 +9,14 @@ namespace FilterLists.Services.FilterList.MappingProfiles
|
|||
[UsedImplicitly]
|
||||
public class ListSummaryDtoMappingProfile : Profile
|
||||
{
|
||||
private readonly Func<Data.Entities.Snapshot, bool> isDiffSnapshot =
|
||||
s => s.AddedSnapshotRules.Count > 0 || s.RemovedSnapshotRules.Count > 0;
|
||||
|
||||
private readonly Func<Data.Entities.Snapshot, bool> isSuccessfulSnapshot =
|
||||
s => s.IsCompleted && s.HttpStatusCode == "200";
|
||||
|
||||
public ListSummaryDtoMappingProfile() =>
|
||||
CreateMap<Data.Entities.FilterList, ListSummaryDto>()
|
||||
.ForMember(d => d.AddedDate, c => c.MapFrom(l => l.CreatedDateUtc))
|
||||
.ForMember(d => d.Languages, c => c.MapFrom(l => l.FilterListLanguages.Select(la => la.Language)))
|
||||
.ForMember(d => d.UpdatedDate,
|
||||
c => c.MapFrom(l =>
|
||||
l.Snapshots.Where(isSuccessfulSnapshot)
|
||||
.Where(isDiffSnapshot)
|
||||
l.Snapshots.Where(s => s.IsCompleted && s.HttpStatusCode == "200")
|
||||
.Where(s => s.AddedSnapshotRules.Count > 0 || s.RemovedSnapshotRules.Count > 0)
|
||||
.OrderByDescending(s => s.CreatedDateUtc)
|
||||
.Select(s => s.CreatedDateUtc)
|
||||
.Cast<DateTime?>()
|
||||
|
|
|
|||
Loading…
Reference in a new issue