no update fechas

Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
Omar Sánchez Pizarro
2026-01-20 12:50:03 +01:00
parent a65bedf24d
commit 421fee1938
3 changed files with 51 additions and 33 deletions

View File

@@ -39,13 +39,7 @@ router.get('/', basicAuthMiddleware, async (req, res) => {
const limit = parseInt(req.query.limit) || 100;
const offset = parseInt(req.query.offset) || 0;
// Los artículos ya vienen ordenados de MongoDB, pero asegurémonos
const sorted = articles.sort((a, b) => {
const aTime = typeof a.notifiedAt === 'number' ? a.notifiedAt : new Date(a.notifiedAt).getTime();
const bTime = typeof b.notifiedAt === 'number' ? b.notifiedAt : new Date(b.notifiedAt).getTime();
return bTime - aTime;
});
const paginated = sorted.slice(offset, offset + limit);
const paginated = articles.slice(offset, offset + limit);
res.json({
articles: paginated,
@@ -124,16 +118,9 @@ router.get('/search', basicAuthMiddleware, async (req, res) => {
return false;
});
// Ordenar por fecha de notificación (más recientes primero)
const sorted = filtered.sort((a, b) => {
const aTime = typeof a.notifiedAt === 'number' ? a.notifiedAt : new Date(a.notifiedAt).getTime();
const bTime = typeof b.notifiedAt === 'number' ? b.notifiedAt : new Date(b.notifiedAt).getTime();
return bTime - aTime;
});
res.json({
articles: sorted,
total: sorted.length,
articles: filtered,
total: filtered.length,
query: query,
});
} catch (error) {