save checkpoint: save features
This commit is contained in:
@@ -160,7 +160,7 @@ app.MapPost("/api/v1/packs", async (PackUploadRequest request, PackService servi
|
||||
.Produces(StatusCodes.Status400BadRequest)
|
||||
.Produces(StatusCodes.Status401Unauthorized);
|
||||
|
||||
app.MapGet("/api/v1/packs", async (string? tenant, PackService service, HttpContext context, AuthOptions auth, CancellationToken cancellationToken) =>
|
||||
app.MapGet("/api/v1/packs", async (string? tenant, bool? includeDeprecated, PackService service, LifecycleService lifecycleService, HttpContext context, AuthOptions auth, CancellationToken cancellationToken) =>
|
||||
{
|
||||
if (!IsAuthorized(context, auth, out var unauthorizedResult))
|
||||
{
|
||||
@@ -180,6 +180,16 @@ app.MapGet("/api/v1/packs", async (string? tenant, PackService service, HttpCont
|
||||
}
|
||||
|
||||
var packs = await service.ListAsync(effectiveTenant, cancellationToken).ConfigureAwait(false);
|
||||
if (includeDeprecated is not true)
|
||||
{
|
||||
var lifecycle = await lifecycleService.ListAsync(effectiveTenant, cancellationToken).ConfigureAwait(false);
|
||||
var deprecatedPackIds = lifecycle
|
||||
.Where(static l => string.Equals(l.State, "deprecated", StringComparison.OrdinalIgnoreCase))
|
||||
.Select(static l => l.PackId)
|
||||
.ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
packs = packs.Where(p => !deprecatedPackIds.Contains(p.PackId)).ToList();
|
||||
}
|
||||
|
||||
return Results.Ok(packs.Select(PackResponse.From));
|
||||
})
|
||||
.Produces<IEnumerable<PackResponse>>(StatusCodes.Status200OK)
|
||||
|
||||
Reference in New Issue
Block a user