fix(admin): pre-compute pagination in Java, remove arithmetic from Qute template
Deploy to Production / deploy (push) Successful in 3m12s

Qute cannot evaluate + and * as arithmetic operators at runtime even with
requireTypeSafeExpressions=false — it tries to look them up as map keys.
Pre-compute hasPrev/hasNext/displayPage/prevPage/nextPage in the resource.

Co-Authored-By: Mira Rehfeld <noreply@anthropic.com>
This commit is contained in:
Carsten Rehfeld
2026-05-16 21:55:18 +02:00
parent 60dfcd58f6
commit 51e210ab68
2 changed files with 12 additions and 8 deletions
@@ -26,9 +26,10 @@ public class SandboxListResource {
@ConfigProperty(name = "apix.admin.key")
String adminKey;
@CheckedTemplate(requireTypeSafeExpressions = false)
@CheckedTemplate
static class Templates {
static native TemplateInstance list(AdminSandboxListResponse result, int page, int size, String tier);
static native TemplateInstance list(AdminSandboxListResponse result, int page, int size, String tier,
boolean hasPrev, boolean hasNext, int displayPage, int prevPage, int nextPage);
static native TemplateInstance error(String message);
}
@@ -40,7 +41,10 @@ public class SandboxListResource {
try {
String tierParam = tier.isBlank() ? null : tier;
AdminSandboxListResponse result = registry.listSandboxes(adminKey, page, size, tierParam);
return Templates.list(result, page, size, tier);
boolean hasPrev = page > 0;
boolean hasNext = (long)(page + 1) * size < result.total();
return Templates.list(result, page, size, tier,
hasPrev, hasNext, page + 1, page - 1, page + 1);
} catch (Exception e) {
LOG.errorf(e, "Failed to load sandbox list");
return Templates.error("Could not load sandbox list");
@@ -103,12 +103,12 @@ tr:hover td { background: #161b22; }
</table>
<div class="pagination">
{#if page > 0}
<a class="page-link" href="/sandboxes?page={page - 1}&size={size}&tier={tier}">← Previous</a>
{#if hasPrev}
<a class="page-link" href="/sandboxes?page={prevPage}&size={size}&tier={tier}">← Previous</a>
{/if}
<span class="page-info">Page {page + 1} · {result.sandboxes.size} of {result.total}</span>
{#if (page + 1) * size < result.total}
<a class="page-link" href="/sandboxes?page={page + 1}&size={size}&tier={tier}">Next →</a>
<span class="page-info">Page {displayPage} · {result.sandboxes.size} of {result.total}</span>
{#if hasNext}
<a class="page-link" href="/sandboxes?page={nextPage}&size={size}&tier={tier}">Next →</a>
{/if}
</div>