Fix completed simulation history cursor

This commit is contained in:
hz
2026-07-14 21:21:13 -05:00
parent 78ab8c21f6
commit 0f43a51f2b
2 changed files with 11 additions and 3 deletions
@@ -41,8 +41,15 @@ public class ExamSimulationsController(ExamSimulationStore simulations) : Contro
}
[HttpGet("completed")]
public async Task<IActionResult> Completed([FromQuery] int limit = 20, [FromQuery] DateTime? before = null) =>
Ok(await simulations.GetCompletedAsync(UserId(), limit, before));
public async Task<IActionResult> Completed([FromQuery] int limit = 20, [FromQuery] string? before = null)
{
DateTime? cursor = null;
if (!string.IsNullOrWhiteSpace(before) && !DateTime.TryParse(before, null, System.Globalization.DateTimeStyles.RoundtripKind, out var parsed))
return BadRequest("The completed-simulation cursor is invalid.");
else if (!string.IsNullOrWhiteSpace(before))
cursor = parsed;
return Ok(await simulations.GetCompletedAsync(UserId(), limit, cursor));
}
[HttpGet("{id}")]
public async Task<IActionResult> Get(string id)
+2 -1
View File
@@ -173,7 +173,8 @@ func _on_request_completed(result: int, response_code: int, _headers: PackedStri
if action == "history" or action == "history_append":
var items: Array = parsed.get("items", [])
completed_history = completed_history + items if action == "history_append" else items
completed_history_next_before = str(parsed.get("nextBefore", ""))
var next_before: Variant = parsed.get("nextBefore", null)
completed_history_next_before = "" if next_before == null else str(next_before)
completed_history_changed.emit()
return
if action.begins_with("outcome_"):