update lists endpoint

ref #505
This commit is contained in:
Collin Barrett 2018-09-24 19:06:39 -05:00
parent be67e4cccb
commit d0568e76df
5 changed files with 1 additions and 76 deletions

View file

@ -18,18 +18,6 @@ public ListsController(IMemoryCache memoryCache, SeedService seedService, Filter
[HttpGet]
public async Task<IActionResult> Index() =>
Json(await MemoryCache.GetOrCreate("ListsController_Index", entry =>
{
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
return filterListService.GetAllSummariesAsync();
}));
/// <summary>
/// in development for https://github.com/collinbarrett/FilterLists/issues/505
/// </summary>
[HttpGet]
[Route("alpha")]
public async Task<IActionResult> Alpha() =>
Json(await MemoryCache.GetOrCreate("ListsController_Alpha", entry =>
{
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
return filterListService.GetIndexAsync();

View file

@ -16,12 +16,6 @@ public FilterListService(FilterListsDbContext dbContext, IConfigurationProvider
{
}
public async Task<IEnumerable<ListSummaryDto>> GetAllSummariesAsync() =>
await DbContext.FilterLists
.OrderBy(l => l.Name)
.ProjectTo<ListSummaryDto>(MapConfig)
.ToListAsync();
public async Task<IEnumerable<ListIndexRecord>> GetIndexAsync() =>
await DbContext.FilterLists
.OrderBy(l => l.Name)

View file

@ -1,40 +0,0 @@
using System.Linq;
using AutoMapper;
using FilterLists.Services.FilterList.Models;
using JetBrains.Annotations;
namespace FilterLists.Services.FilterList.MappingProfiles
{
[UsedImplicitly]
public class ListSummaryDtoMappingProfile : Profile
{
public ListSummaryDtoMappingProfile() =>
CreateMap<Data.Entities.FilterList, ListSummaryDto>()
.ForMember(dest => dest.Id,
opt => opt.MapFrom(src =>
(int)src.Id))
.ForMember(dest => dest.Languages,
opt => opt.MapFrom(src =>
src.FilterListLanguages.Select(la => la.Language)))
.ForMember(dest => dest.SoftwareIds,
opt => opt.MapFrom(src =>
src.Syntax
.SoftwareSyntaxes
.Select(ss => ss.Software)
.OrderBy(s => s.Name)
.Select(s => (int)s.Id)))
.ForMember(dest => dest.Tags,
opt => opt.MapFrom(src =>
src.FilterListTags.Select(m => m.Tag)))
.ForMember(dest => dest.UpdatedDate,
opt => opt.MapFrom(src =>
src.DiscontinuedDate ??
(src.Snapshots.Count(s => s.WasSuccessful && s.Md5Checksum != null) >= 2
? src.Snapshots
.Where(s => s.WasSuccessful && s.Md5Checksum != null)
.Select(s => s.CreatedDateUtc)
.OrderByDescending(c => c)
.FirstOrDefault()
: null)));
}
}

View file

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using JetBrains.Annotations;
namespace FilterLists.Services.FilterList.Models
{
[UsedImplicitly]
public class ListSummaryDto
{
public int Id { get; set; }
public IEnumerable<ListLanguagesDto> Languages { get; set; }
public string Name { get; set; }
public IEnumerable<int> SoftwareIds { get; set; }
public IEnumerable<ListTagDto> Tags { get; set; }
public DateTime? UpdatedDate { get; set; }
}
}

View file

@ -32,7 +32,7 @@ export class HomeContainer extends React.Component<{}, IState> {
};
fetchLists() {
fetch("https://filterlists.com/api/v1/lists/alpha")
fetch("https://filterlists.com/api/v1/lists")
.then(r => r.json() as Promise<IList[]>)
.then(d => { this.setState({ lists: d }); });
};