mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
parent
e03bc675d3
commit
b6395458a8
12 changed files with 94 additions and 33 deletions
|
|
@ -10,7 +10,7 @@ namespace FilterLists.Api.V1.Controllers
|
|||
[Route("v{version:apiVersion}/[controller]")]
|
||||
public class BaseController : Controller
|
||||
{
|
||||
protected readonly TimeSpan AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(4);
|
||||
protected static readonly TimeSpan FourHoursFromNow = TimeSpan.FromHours(4);
|
||||
protected readonly IMemoryCache MemoryCache;
|
||||
protected readonly SeedService SeedService;
|
||||
|
||||
|
|
@ -18,8 +18,6 @@ public BaseController()
|
|||
{
|
||||
}
|
||||
|
||||
protected BaseController(SeedService seedService) => SeedService = seedService;
|
||||
|
||||
protected BaseController(IMemoryCache memoryCache, SeedService seedService)
|
||||
{
|
||||
MemoryCache = memoryCache;
|
||||
|
|
|
|||
|
|
@ -3,18 +3,23 @@
|
|||
using FilterLists.Services.Seed;
|
||||
using FilterLists.Services.Seed.Models.Junctions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
public class ForksController : BaseController
|
||||
{
|
||||
public ForksController(SeedService seedService) : base(seedService)
|
||||
public ForksController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache, seedService)
|
||||
{
|
||||
}
|
||||
|
||||
[HttpGet("seed")]
|
||||
public async Task<IActionResult> Seed() =>
|
||||
Json(await SeedService.GetAllAsync<Fork, ForkSeedDto>(typeof(Fork).GetProperty("UpstreamFilterListId"),
|
||||
typeof(Fork).GetProperty("ForkFilterListId")));
|
||||
Json(await MemoryCache.GetOrCreate("ForksController_Seed", entry =>
|
||||
{
|
||||
entry.AbsoluteExpirationRelativeToNow = FourHoursFromNow;
|
||||
return SeedService.GetAllAsync<Fork, ForkSeedDto>(typeof(Fork).GetProperty("UpstreamFilterListId"),
|
||||
typeof(Fork).GetProperty("ForkFilterListId"));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,16 +3,22 @@
|
|||
using FilterLists.Services.Seed;
|
||||
using FilterLists.Services.Seed.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
public class LanguagesController : BaseController
|
||||
{
|
||||
public LanguagesController(SeedService seedService) : base(seedService)
|
||||
public LanguagesController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache, seedService)
|
||||
{
|
||||
}
|
||||
|
||||
[HttpGet("seed")]
|
||||
public async Task<IActionResult> Seed() => Json(await SeedService.GetAllAsync<Language, LanguageSeedDto>());
|
||||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("LanguagesController_Seed", entry =>
|
||||
{
|
||||
entry.AbsoluteExpirationRelativeToNow = FourHoursFromNow;
|
||||
return SeedService.GetAllAsync<Language, LanguageSeedDto>();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,16 +3,22 @@
|
|||
using FilterLists.Services.Seed;
|
||||
using FilterLists.Services.Seed.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
public class LicensesController : BaseController
|
||||
{
|
||||
public LicensesController(SeedService seedService) : base(seedService)
|
||||
public LicensesController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache, seedService)
|
||||
{
|
||||
}
|
||||
|
||||
[HttpGet("seed")]
|
||||
public async Task<IActionResult> Seed() => Json(await SeedService.GetAllAsync<License, LicenseSeedDto>());
|
||||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("LicensesController_Seed", entry =>
|
||||
{
|
||||
entry.AbsoluteExpirationRelativeToNow = FourHoursFromNow;
|
||||
return SeedService.GetAllAsync<License, LicenseSeedDto>();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ public ListsController(IMemoryCache memoryCache, SeedService seedService, Filter
|
|||
public async Task<IActionResult> Index() =>
|
||||
Json(await MemoryCache.GetOrCreate("ListsController_Index", entry =>
|
||||
{
|
||||
entry.AbsoluteExpirationRelativeToNow = AbsoluteExpirationRelativeToNow;
|
||||
entry.AbsoluteExpirationRelativeToNow = FourHoursFromNow;
|
||||
return filterListService.GetAllSummariesAsync();
|
||||
}));
|
||||
|
||||
|
|
@ -29,11 +29,16 @@ public async Task<IActionResult> Index() =>
|
|||
public async Task<IActionResult> GetById(int id) =>
|
||||
Json(await MemoryCache.GetOrCreate("ListsController_GetById_" + id, entry =>
|
||||
{
|
||||
entry.AbsoluteExpirationRelativeToNow = AbsoluteExpirationRelativeToNow;
|
||||
entry.AbsoluteExpirationRelativeToNow = FourHoursFromNow;
|
||||
return filterListService.GetDetailsAsync((uint)id);
|
||||
}));
|
||||
|
||||
[HttpGet("seed")]
|
||||
public async Task<IActionResult> Seed() => Json(await SeedService.GetAllAsync<FilterList, FilterListSeedDto>());
|
||||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("ListsController_Seed", entry =>
|
||||
{
|
||||
entry.AbsoluteExpirationRelativeToNow = FourHoursFromNow;
|
||||
return SeedService.GetAllAsync<FilterList, FilterListSeedDto>();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,19 +3,25 @@
|
|||
using FilterLists.Services.Seed;
|
||||
using FilterLists.Services.Seed.Models.Junctions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
public class ListsLanguagesController : BaseController
|
||||
{
|
||||
public ListsLanguagesController(SeedService seedService) : base(seedService)
|
||||
public ListsLanguagesController(IMemoryCache memoryCache, SeedService seedService)
|
||||
: base(memoryCache, seedService)
|
||||
{
|
||||
}
|
||||
|
||||
[HttpGet("seed")]
|
||||
public async Task<IActionResult> Seed() =>
|
||||
Json(await SeedService.GetAllAsync<FilterListLanguage, FilterListLanguageSeedDto>(
|
||||
typeof(FilterListLanguage).GetProperty("FilterListId"),
|
||||
typeof(FilterListLanguage).GetProperty("LanguageId")));
|
||||
Json(await MemoryCache.GetOrCreate("ListsLanguagesController_Seed", entry =>
|
||||
{
|
||||
entry.AbsoluteExpirationRelativeToNow = FourHoursFromNow;
|
||||
return SeedService.GetAllAsync<FilterListLanguage, FilterListLanguageSeedDto>(
|
||||
typeof(FilterListLanguage).GetProperty("FilterListId"),
|
||||
typeof(FilterListLanguage).GetProperty("LanguageId"));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,19 +3,25 @@
|
|||
using FilterLists.Services.Seed;
|
||||
using FilterLists.Services.Seed.Models.Junctions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
public class ListsMaintainersController : BaseController
|
||||
{
|
||||
public ListsMaintainersController(SeedService seedService) : base(seedService)
|
||||
public ListsMaintainersController(IMemoryCache memoryCache, SeedService seedService)
|
||||
: base(memoryCache, seedService)
|
||||
{
|
||||
}
|
||||
|
||||
[HttpGet("seed")]
|
||||
public async Task<IActionResult> Seed() =>
|
||||
Json(await SeedService.GetAllAsync<FilterListMaintainer, FilterListMaintainerSeedDto>(
|
||||
typeof(FilterListMaintainer).GetProperty("MaintainerId"),
|
||||
typeof(FilterListMaintainer).GetProperty("FilterListId")));
|
||||
Json(await MemoryCache.GetOrCreate("ListsMaintainersController_Seed", entry =>
|
||||
{
|
||||
entry.AbsoluteExpirationRelativeToNow = FourHoursFromNow;
|
||||
return SeedService.GetAllAsync<FilterListMaintainer, FilterListMaintainerSeedDto>(
|
||||
typeof(FilterListMaintainer).GetProperty("MaintainerId"),
|
||||
typeof(FilterListMaintainer).GetProperty("FilterListId"));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,16 +3,22 @@
|
|||
using FilterLists.Services.Seed;
|
||||
using FilterLists.Services.Seed.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
public class MaintainersController : BaseController
|
||||
{
|
||||
public MaintainersController(SeedService seedService) : base(seedService)
|
||||
public MaintainersController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache, seedService)
|
||||
{
|
||||
}
|
||||
|
||||
[HttpGet("seed")]
|
||||
public async Task<IActionResult> Seed() => Json(await SeedService.GetAllAsync<Maintainer, MaintainerSeedDto>());
|
||||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("MaintainersController_Seed", entry =>
|
||||
{
|
||||
entry.AbsoluteExpirationRelativeToNow = FourHoursFromNow;
|
||||
return SeedService.GetAllAsync<Maintainer, MaintainerSeedDto>();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,18 +3,23 @@
|
|||
using FilterLists.Services.Seed;
|
||||
using FilterLists.Services.Seed.Models.Junctions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
public class MergesController : BaseController
|
||||
{
|
||||
public MergesController(SeedService seedService) : base(seedService)
|
||||
public MergesController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache, seedService)
|
||||
{
|
||||
}
|
||||
|
||||
[HttpGet("seed")]
|
||||
public async Task<IActionResult> Seed() =>
|
||||
Json(await SeedService.GetAllAsync<Merge, MergeSeedDto>(typeof(Merge).GetProperty("MergeFilterListId"),
|
||||
typeof(Merge).GetProperty("UpstreamFilterListId")));
|
||||
Json(await MemoryCache.GetOrCreate("MergesController_Seed", entry =>
|
||||
{
|
||||
entry.AbsoluteExpirationRelativeToNow = FourHoursFromNow;
|
||||
return SeedService.GetAllAsync<Merge, MergeSeedDto>(typeof(Merge).GetProperty("MergeFilterListId"),
|
||||
typeof(Merge).GetProperty("UpstreamFilterListId"));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,16 +3,22 @@
|
|||
using FilterLists.Services.Seed;
|
||||
using FilterLists.Services.Seed.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
public class SoftwareController : BaseController
|
||||
{
|
||||
public SoftwareController(SeedService seedService) : base(seedService)
|
||||
public SoftwareController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache, seedService)
|
||||
{
|
||||
}
|
||||
|
||||
[HttpGet("seed")]
|
||||
public async Task<IActionResult> Seed() => Json(await SeedService.GetAllAsync<Software, SoftwareSeedDto>());
|
||||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("SoftwareController_Seed", entry =>
|
||||
{
|
||||
entry.AbsoluteExpirationRelativeToNow = FourHoursFromNow;
|
||||
return SeedService.GetAllAsync<Software, SoftwareSeedDto>();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,18 +3,24 @@
|
|||
using FilterLists.Services.Seed;
|
||||
using FilterLists.Services.Seed.Models.Junctions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
public class SoftwareSyntaxesController : BaseController
|
||||
{
|
||||
public SoftwareSyntaxesController(SeedService seedService) : base(seedService)
|
||||
public SoftwareSyntaxesController(IMemoryCache memoryCache, SeedService seedService)
|
||||
: base(memoryCache, seedService)
|
||||
{
|
||||
}
|
||||
|
||||
[HttpGet("seed")]
|
||||
public async Task<IActionResult> Seed() =>
|
||||
Json(await SeedService.GetAllAsync<SoftwareSyntax, SoftwareSyntaxSeedDto>(
|
||||
typeof(SoftwareSyntax).GetProperty("SyntaxId"), typeof(SoftwareSyntax).GetProperty("SoftwareId")));
|
||||
Json(await MemoryCache.GetOrCreate("SoftwareSyntaxesController_Seed", entry =>
|
||||
{
|
||||
entry.AbsoluteExpirationRelativeToNow = FourHoursFromNow;
|
||||
return SeedService.GetAllAsync<SoftwareSyntax, SoftwareSyntaxSeedDto>(
|
||||
typeof(SoftwareSyntax).GetProperty("SyntaxId"), typeof(SoftwareSyntax).GetProperty("SoftwareId"));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,16 +3,22 @@
|
|||
using FilterLists.Services.Seed;
|
||||
using FilterLists.Services.Seed.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
public class SyntaxesController : BaseController
|
||||
{
|
||||
public SyntaxesController(SeedService seedService) : base(seedService)
|
||||
public SyntaxesController(IMemoryCache memoryCache, SeedService seedService) : base(memoryCache, seedService)
|
||||
{
|
||||
}
|
||||
|
||||
[HttpGet("seed")]
|
||||
public async Task<IActionResult> Seed() => Json(await SeedService.GetAllAsync<Syntax, SyntaxSeedDto>());
|
||||
public async Task<IActionResult> Seed() =>
|
||||
Json(await MemoryCache.GetOrCreate("SyntaxesController_Seed", entry =>
|
||||
{
|
||||
entry.AbsoluteExpirationRelativeToNow = FourHoursFromNow;
|
||||
return SeedService.GetAllAsync<Syntax, SyntaxSeedDto>();
|
||||
}));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue