no update fechas
Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user