fix(api): next=null sur dernière page en mode agrégation (#78)

Si la page retournée est partielle (len < page_size), on sait qu'on est
sur la dernière page → next=null, parité data.gouv.fr.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Colin Maudry
2026-06-22 14:23:09 +02:00
parent 70ee819a51
commit c264c36684
+5 -1
View File
@@ -202,10 +202,14 @@ def data():
offset=(page - 1) * page_size, offset=(page - 1) * page_size,
) )
df_ready = df.with_columns(cs.temporal().cast(pl.String)) df_ready = df.with_columns(cs.temporal().cast(pl.String))
# Si la page est partielle, on connaît le total exact ; sinon on ne sait pas.
agg_total = (
(page - 1) * page_size + df.height if df.height < page_size else None
)
return { return {
"data": df_ready.to_dicts(), "data": df_ready.to_dicts(),
"meta": {"page": page, "page_size": page_size}, "meta": {"page": page, "page_size": page_size},
"links": _build_links(page, page_size, None), "links": _build_links(page, page_size, agg_total),
} }
df = query_marches( df = query_marches(