fix list rulecounts

This commit is contained in:
Collin M. Barrett 2018-08-24 14:54:14 -05:00
parent f11245eea4
commit bac92c183d
5 changed files with 20 additions and 16 deletions

View file

@ -8,16 +8,21 @@ namespace FilterLists.Services.FilterList.MappingProfiles
[UsedImplicitly]
public class ListDetailsDtoMappingProfile : Profile
{
//TODO: fix UpdatedDate and RuleCount
public ListDetailsDtoMappingProfile() =>
CreateMap<Data.Entities.FilterList, ListDetailsDto>()
.ForMember(d => d.Languages, c => c.MapFrom(l => l.FilterListLanguages.Select(la => la.Language.Name)))
.ForMember(d => d.Maintainers, c => c.MapFrom(l => l.FilterListMaintainers.Select(m => m.Maintainer)))
.ForMember(d => d.Tags, c => c.MapFrom(l => l.FilterListTags.Select(m => m.Tag)))
.ForMember(d => d.RuleCount,
c => c.MapFrom(l => 0))
.ForMember(d => d.UpdatedDate,
c => c.MapFrom(l =>
l.ModifiedDateUtc));
.ForMember(d => d.Languages, o => o.MapFrom(l => l.FilterListLanguages.Select(la => la.Language.Name)))
.ForMember(d => d.Maintainers, o => o.MapFrom(l => l.FilterListMaintainers.Select(m => m.Maintainer)))
.ForMember(d => d.Tags, o => o.MapFrom(l => l.FilterListTags.Select(m => m.Tag)))
.ForMember(d => d.RuleCount, o => o.MapFrom(l =>
l.Snapshots
.Count(s => s.WasSuccessful) > 0
? l.Snapshots
.Where(s => s.WasSuccessful)
.OrderByDescending(s => s.CreatedDateUtc)
.FirstOrDefault()
.SnapshotRules
.Count
: 0))
.ForMember(d => d.UpdatedDate, o => o.MapFrom(l => l.ModifiedDateUtc));
}
}

View file

@ -12,6 +12,6 @@ public class ListMaintainerDtoMappingProfile : Profile
public ListMaintainerDtoMappingProfile() =>
CreateMap<Maintainer, ListMaintainerDto>()
.ForMember(d => d.AdditionalLists,
c => c.MapFrom(m => m.FilterListMaintainers.Select(lm => lm.FilterList)));
o => o.MapFrom(m => m.FilterListMaintainers.Select(lm => lm.FilterList)));
}
}

View file

@ -8,11 +8,10 @@ namespace FilterLists.Services.FilterList.MappingProfiles
[UsedImplicitly]
public class ListSummaryDtoMappingProfile : Profile
{
//TODO: fix UpdatedDate to look at most recent snapshot with changes
public ListSummaryDtoMappingProfile() =>
CreateMap<Data.Entities.FilterList, ListSummaryDto>()
.ForMember(d => d.Languages, c => c.MapFrom(l => l.FilterListLanguages.Select(la => la.Language)))
.ForMember(d => d.Tags, c => c.MapFrom(l => l.FilterListTags.Select(m => m.Tag)))
.ForMember(d => d.UpdatedDate, c => c.MapFrom(l => l.ModifiedDateUtc));
.ForMember(d => d.Languages, o => o.MapFrom(l => l.FilterListLanguages.Select(la => la.Language)))
.ForMember(d => d.Tags, o => o.MapFrom(l => l.FilterListTags.Select(m => m.Tag)))
.ForMember(d => d.UpdatedDate, o => o.MapFrom(l => l.ModifiedDateUtc));
}
}

View file

@ -11,6 +11,6 @@ public class ListSyntaxDtoMappingProfile : Profile
{
public ListSyntaxDtoMappingProfile() =>
CreateMap<Syntax, ListSyntaxDto>()
.ForMember(d => d.SupportedSoftware, c => c.MapFrom(s => s.SoftwareSyntaxes.Select(ss => ss.Software)));
.ForMember(d => d.SupportedSoftware, o => o.MapFrom(s => s.SoftwareSyntaxes.Select(ss => ss.Software)));
}
}

View file

@ -9,6 +9,6 @@ namespace FilterLists.Services.FilterList.MappingProfiles
public class ListTagDtoMappingProfile : Profile
{
public ListTagDtoMappingProfile() =>
CreateMap<Tag, ListTagDto>().ForMember(d => d.ColorHex, c => c.MapFrom(m => TagColors.Colors[(int)m.Id]));
CreateMap<Tag, ListTagDto>().ForMember(d => d.ColorHex, o => o.MapFrom(m => TagColors.Colors[(int)m.Id]));
}
}