feat(dir): include primaryViewUrl in /lists endpoint

This commit is contained in:
Collin M. Barrett 2021-11-02 15:44:21 -05:00
parent fc177fde3e
commit 2510a7e426
2 changed files with 7 additions and 1 deletions

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
namespace FilterLists.Directory.Api.Contracts.Models
{
@ -11,6 +12,7 @@ public class ListVm
public IEnumerable<int>? SyntaxIds { get; init; }
public IEnumerable<string>? Iso6391s { get; init; }
public IEnumerable<int>? TagIds { get; init; }
public Uri? PrimaryViewUrl { get; init; }
public IEnumerable<int>? MaintainerIds { get; init; }
}
}

View file

@ -54,6 +54,10 @@ public ListVmProfile()
.ForMember(fl => fl.TagIds,
o => o.MapFrom(fl =>
fl.FilterListTags.Select(flt => flt.TagId).OrderBy(tid => tid).AsEnumerable()))
.ForMember(fl => fl.PrimaryViewUrl,
o => o.MapFrom(fl =>
fl.ViewUrls.OrderBy(u => u.SegmentNumber).ThenBy(u => u.Primariness).Select(u => u.Url)
.FirstOrDefault()))
.ForMember(fl => fl.MaintainerIds,
o => o.MapFrom(fl =>
fl.FilterListMaintainers.Select(flm => flm.MaintainerId).OrderBy(mid => mid)