Fix completed simulation history cursor
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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_"):
|
||||
|
||||
Reference in New Issue
Block a user