mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
GraphQL endpoints for modlist status
This commit is contained in:
parent
5d22e3d094
commit
a9362f51e8
@ -19,7 +19,7 @@ namespace Wabbajack.BuildServer.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("status")]
|
[Route("status.json")]
|
||||||
public async Task<IList<ModlistSummary>> HandleGetLists()
|
public async Task<IList<ModlistSummary>> HandleGetLists()
|
||||||
{
|
{
|
||||||
return await Db.ModListStatus.AsQueryable().Select(m => m.Summary).ToListAsync();
|
return await Db.ModListStatus.AsQueryable().Select(m => m.Summary).ToListAsync();
|
||||||
|
67
Wabbajack.BuildServer/GraphQL/ModlistStatusType.cs
Normal file
67
Wabbajack.BuildServer/GraphQL/ModlistStatusType.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using GraphQL.Types;
|
||||||
|
using Wabbajack.BuildServer.Models;
|
||||||
|
using Wabbajack.Lib.ModListRegistry;
|
||||||
|
|
||||||
|
namespace Wabbajack.BuildServer.GraphQL
|
||||||
|
{
|
||||||
|
public class ModListStatusType : ObjectGraphType<ModListStatus>
|
||||||
|
{
|
||||||
|
public ModListStatusType()
|
||||||
|
{
|
||||||
|
Name = "ModlistSummary";
|
||||||
|
Description = "Short summary of a modlist status";
|
||||||
|
Field(x => x.Id).Description("Name of the modlist");
|
||||||
|
Field(x => x.Metadata.Title).Description("Human-friendly name of the modlist");
|
||||||
|
Field<ListGraphType<ModListArchiveType>>("Archives",
|
||||||
|
arguments: new QueryArguments(new QueryArgument<ArchiveEnumFilterType>
|
||||||
|
{
|
||||||
|
Name = "filter", Description = "Type of archives to return"
|
||||||
|
}),
|
||||||
|
resolve: context =>
|
||||||
|
{
|
||||||
|
var arg = context.GetArgument<string>("filter");
|
||||||
|
var archives = (IEnumerable<DetailedStatusItem>)context.Source.DetailedStatus.Archives;
|
||||||
|
switch (arg)
|
||||||
|
{
|
||||||
|
case "FAILED":
|
||||||
|
archives = archives.Where(a => a.IsFailing);
|
||||||
|
break;
|
||||||
|
case "PASSED":
|
||||||
|
archives = archives.Where(a => !a.IsFailing);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return archives;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ModListArchiveType : ObjectGraphType<DetailedStatusItem>
|
||||||
|
{
|
||||||
|
public ModListArchiveType()
|
||||||
|
{
|
||||||
|
Field(x => x.IsFailing).Description("Is this archive failing validation?");
|
||||||
|
Field(x => x.Archive.Name).Description("Name of the archive");
|
||||||
|
Field(x => x.Archive.Hash).Description("Hash of the archive");
|
||||||
|
Field(x => x.Archive.Size).Description("Size of the archive");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ArchiveEnumFilterType : EnumerationGraphType
|
||||||
|
{
|
||||||
|
public ArchiveEnumFilterType()
|
||||||
|
{
|
||||||
|
Name = "ArchiveFilterEnum";
|
||||||
|
Description = "What archives should be returned from a sublist";
|
||||||
|
AddValue("ALL", "All archives are returned", "ALL");
|
||||||
|
AddValue("FAILED", "All archives are returned", "FAILED");
|
||||||
|
AddValue("PASSED", "All archives are returned", "PASSED");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,30 @@ namespace Wabbajack.BuildServer.GraphQL
|
|||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
FieldAsync<ListGraphType<ModListStatusType>>("modLists",
|
||||||
|
arguments: new QueryArguments(new QueryArgument<ArchiveEnumFilterType>
|
||||||
|
{
|
||||||
|
Name = "filter", Description = "Filter lists to those that only have these archive classifications"
|
||||||
|
}),
|
||||||
|
resolve: async context =>
|
||||||
|
{
|
||||||
|
var arg = context.GetArgument<string>("filter");
|
||||||
|
var lists = db.ModListStatus.AsQueryable();
|
||||||
|
switch (arg)
|
||||||
|
{
|
||||||
|
case "FAILED":
|
||||||
|
lists = lists.Where(l => l.DetailedStatus.HasFailures);
|
||||||
|
break;
|
||||||
|
case "PASSED":
|
||||||
|
lists = lists.Where(a => !a.DetailedStatus.HasFailures);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return await lists.ToListAsync();
|
||||||
|
});
|
||||||
|
|
||||||
FieldAsync<ListGraphType<JobType>>("job",
|
FieldAsync<ListGraphType<JobType>>("job",
|
||||||
arguments: new QueryArguments(
|
arguments: new QueryArguments(
|
||||||
new QueryArgument<IdGraphType> {Name = "id", Description = "Id of the Job"}),
|
new QueryArgument<IdGraphType> {Name = "id", Description = "Id of the Job"}),
|
||||||
|
Loading…
Reference in New Issue
Block a user