Skip to content

Commit

Permalink
fixed query for run results
Browse files Browse the repository at this point in the history
  • Loading branch information
omergunr100 committed Sep 5, 2024
1 parent 6802bf6 commit 254f03a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
9 changes: 6 additions & 3 deletions NetBuddy.Server/Controllers/History/RunHistoryController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Marten;
using JasperFx.Core;
using Marten;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
Expand Down Expand Up @@ -49,10 +50,12 @@ public async Task<IActionResult> GetByRange([FromQuery] int from, [FromQuery] in
.OrderByDescending(x => x.EndAt)
.Skip(from)
.Take(to - from)
.Select(x => x.toDTO())
.ToListAsync();

return Ok(sequenceResults);
_logger.LogDebug($"Found {sequenceResults.Count} results");
_logger.LogDebug($"{sequenceResults}");

return Ok(sequenceResults.Map(result => result.ToDto()));
}

[HttpPut]
Expand Down
16 changes: 16 additions & 0 deletions NetBuddy.Server/DTOs/History/ResultDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using NetBuddy.Server.Models.History;

namespace NetBuddy.Server.DTOs.History;

public sealed class ResultDto
{
public Guid Id { get; set; }

public DateTime StartAt { get; set; }

public DateTime EndAt { get; set; }

public Guid SequenceId { get; set; }

public List<ActionResult> Results { get; set; }

Check warning on line 15 in NetBuddy.Server/DTOs/History/ResultDto.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Results' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
}
15 changes: 8 additions & 7 deletions NetBuddy.Server/Models/History/SequenceResult.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Marten.Schema;
using NetBuddy.Server.DTOs.History;
using NetBuddy.Server.Models.User;

namespace NetBuddy.Server.Models.History;
Expand All @@ -23,15 +24,15 @@ public class SequenceResult
// Owner
public UserAccount? Owner { get; set; }

public object toDTO()
public ResultDto ToDto()
{
return new
return new ResultDto
{
Id,
StartAt,
EndAt,
SequenceId,
Results
Id = Id,
StartAt = StartAt,
EndAt = EndAt,
SequenceId = SequenceId,
Results = Results
};
}
}

0 comments on commit 254f03a

Please sign in to comment.