Fix endpoint that gets resolutions by GPUs.

This commit is contained in:
2025-11-16 04:56:16 +00:00
parent cc2738e45d
commit e5f1d766b5
4 changed files with 32 additions and 35 deletions

View File

@@ -279,7 +279,7 @@ namespace Marechai.App
ApiClientBuilder.RegisterDefaultDeserializer<FormParseNodeFactory>();
if (string.IsNullOrEmpty(RequestAdapter.BaseUrl))
{
RequestAdapter.BaseUrl = "https://localhost:7163";
RequestAdapter.BaseUrl = "http://localhost:5023";
}
PathParameters.TryAdd("baseurl", RequestAdapter.BaseUrl);
}

View File

@@ -12,7 +12,7 @@ using System;
namespace Marechai.App.ResolutionsByGpu.Gpus.Item.Resolutions
{
/// <summary>
/// Builds and executes requests for operations under \resolutions-by-gpu\gpus\{resolutionId}\resolutions
/// Builds and executes requests for operations under \resolutions-by-gpu\gpus\{gpuId}\resolutions
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
public partial class ResolutionsRequestBuilder : BaseRequestBuilder
@@ -22,7 +22,7 @@ namespace Marechai.App.ResolutionsByGpu.Gpus.Item.Resolutions
/// </summary>
/// <param name="pathParameters">Path parameters for the request</param>
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
public ResolutionsRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/resolutions-by-gpu/gpus/{resolutionId}/resolutions", pathParameters)
public ResolutionsRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/resolutions-by-gpu/gpus/{gpuId}/resolutions", pathParameters)
{
}
/// <summary>
@@ -30,7 +30,7 @@ namespace Marechai.App.ResolutionsByGpu.Gpus.Item.Resolutions
/// </summary>
/// <param name="rawUrl">The raw URL to use for the request builder.</param>
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
public ResolutionsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/resolutions-by-gpu/gpus/{resolutionId}/resolutions", rawUrl)
public ResolutionsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/resolutions-by-gpu/gpus/{gpuId}/resolutions", rawUrl)
{
}
/// <returns>A List&lt;global::Marechai.App.Models.ResolutionByGpuDto&gt;</returns>

View File

@@ -1,5 +1,5 @@
{
"descriptionHash": "ABDC74AB94257D5ED6BFBA4E57134BD2B3A4A2C3EC8EC2A514A70334900294CA4391DB5F7404A6055B8B63D0392BB28073F071E07F310F4E650779D5805ACBFF",
"descriptionHash": "DFB5AA54CD7E25D4B216D1E48D3E6F12FDC6C02AC848D74CEC21E4377589A73692313690598744726310A7AD334B7C8F9FA68E6E9A475D6B0B368CE907204194",
"descriptionLocation": "http://localhost:5023/openapi/v1.json",
"lockFileVersion": "1.0.0",
"kiotaVersion": "1.29.0",

View File

@@ -40,39 +40,36 @@ namespace Marechai.Server.Controllers;
[ApiController]
public class ResolutionsByGpuController(MarechaiContext context) : ControllerBase
{
[HttpGet("gpus/{resolutionId:int}/resolutions")]
[HttpGet("gpus/{gpuId:int}/resolutions")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<List<ResolutionByGpuDto>> GetByGpu(int resolutionId) => (await context.ResolutionsByGpu
.Where(r => r.ResolutionId ==
resolutionId)
.Select(r => new ResolutionByGpuDto
{
Id = r.Id,
GpuId = r.GpuId,
Resolution = new ResolutionDto
{
Id = r.Resolution.Id,
Width = r.Resolution.Width,
Height = r.Resolution.Height,
Colors = r.Resolution.Colors,
Palette = r.Resolution
.Palette,
Chars = r.Resolution.Chars,
Grayscale = r.Resolution
.Grayscale
},
ResolutionId = r.ResolutionId
})
.ToListAsync())
.OrderBy(r => r.Resolution.Width)
.ThenBy(r => r.Resolution.Height)
.ThenBy(r => r.Resolution.Chars)
.ThenBy(r => r.Resolution.Grayscale)
.ThenBy(r => r.Resolution.Colors)
.ThenBy(r => r.Resolution.Palette)
.ToList();
public async Task<List<ResolutionByGpuDto>> GetByGpu(int gpuId) => (await context.ResolutionsByGpu
.Where(r => r.GpuId == gpuId)
.Select(r => new ResolutionByGpuDto
{
Id = r.Id,
GpuId = r.GpuId,
Resolution = new ResolutionDto
{
Id = r.Resolution.Id,
Width = r.Resolution.Width,
Height = r.Resolution.Height,
Colors = r.Resolution.Colors,
Palette = r.Resolution.Palette,
Chars = r.Resolution.Chars,
Grayscale = r.Resolution.Grayscale
},
ResolutionId = r.ResolutionId
})
.ToListAsync())
.OrderBy(r => r.Resolution.Width)
.ThenBy(r => r.Resolution.Height)
.ThenBy(r => r.Resolution.Chars)
.ThenBy(r => r.Resolution.Grayscale)
.ThenBy(r => r.Resolution.Colors)
.ThenBy(r => r.Resolution.Palette)
.ToList();
[HttpDelete("{id:long}")]
[Authorize(Roles = "Admin,UberAdmin")]