fix(notifications) : pagination réelle côté provider pour ne plus tronquer à 30 (LST-52)
NotificationProvider retournait findBy(..., 30) : limite codée en dur, paramètre page ignoré et tableau brut (pas un Paginator). hydra:totalItems valait donc 30 → fetchAllHydra s'arrêtait à la 1re page et les notifications restaient tronquées à 30 malgré le correctif front. - NotificationProvider : vraie pagination Doctrine (Pagination + DoctrinePaginator + TraversablePaginator), totalItems réel et hydra:view.next exposés - NotificationRepository : createUserNotificationsQueryBuilder (filtre user + tri) - fetchAllHydra : ne retronque plus silencieusement quand hydra:totalItems est absent, pagine jusqu'à une page non pleine
This commit is contained in:
+16
-2
@@ -33,13 +33,27 @@ export async function fetchAllHydra<T>(
|
||||
const first = await fetchPage(1)
|
||||
const all = extractHydraMembers(first)
|
||||
const total = extractHydraTotal(first)
|
||||
const pageSize = all.length
|
||||
|
||||
if (total === undefined) {
|
||||
// 1ʳᵉ page vide → collection vide, rien de plus à récupérer.
|
||||
if (pageSize === 0) {
|
||||
return all
|
||||
}
|
||||
|
||||
let page = 2
|
||||
while (all.length < total && page <= maxPages) {
|
||||
while (page <= maxPages) {
|
||||
if (total !== undefined) {
|
||||
// Total connu : on s'arrête dès qu'on a tout récupéré.
|
||||
if (all.length >= total) {
|
||||
break
|
||||
}
|
||||
} else if (all.length % pageSize !== 0) {
|
||||
// Total inconnu (provider custom sans `hydra:totalItems`) : la dernière
|
||||
// page récupérée n'était pas pleine → fin de collection. On ne s'arrête
|
||||
// pas en silence sur la 1ʳᵉ page, contrairement à `extractHydraMembers`.
|
||||
break
|
||||
}
|
||||
|
||||
const next = await fetchPage(page)
|
||||
const members = extractHydraMembers(next)
|
||||
if (members.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user