0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-06-25 19:38:40 +00:00

update comments

This commit is contained in:
Víctor Losada Hernández
2026-06-17 15:50:21 +02:00
parent b65105598a
commit a645b61464
+7 -7
View File
@@ -38,7 +38,8 @@ export default function createAdminApi(vite) {
throw { HBErrorCode: '52', code: 401, message: 'Access denied' }; throw { HBErrorCode: '52', code: 401, message: 'Access denied' };
} }
}; };
// Search for up to 300 brews that have not been viewed or updated in 30 days and are shorter than 140 bytes
const junkBrewsPipeline = [ const junkBrewsPipeline = [
{ $match : { { $match : {
updatedAt : { $lt: Moment().subtract(30, 'days').toDate() }, updatedAt : { $lt: Moment().subtract(30, 'days').toDate() },
@@ -49,12 +50,13 @@ export default function createAdminApi(vite) {
{ $limit: 300 } { $limit: 300 }
]; ];
// Search for up to 500 unauthored brews that have not been viewed or updated in two years
const lostBrewsPipeline = [ const lostBrewsPipeline = [
{ {
$match: { $match: {
authors: [], authors: [],
updatedAt: { $lt: Moment().subtract(6, 'years').toDate() }, updatedAt: { $lt: Moment().subtract(2, 'years').toDate() },
lastViewed: { $lt: Moment().subtract(6, 'years').toDate() } lastViewed: { $lt: Moment().subtract(2, 'years').toDate() }
} }
}, },
{ {
@@ -67,7 +69,6 @@ export default function createAdminApi(vite) {
'text' : { '$exists': true } 'text' : { '$exists': true }
}).lean().limit(10000).select('_id'); }).lean().limit(10000).select('_id');
// Search for up to 300 brews that have not been viewed or updated in 30 days and are shorter than 140 bytes
router.get('/admin/cleanupJunk', mw.adminOnly, (req, res)=>{ router.get('/admin/cleanupJunk', mw.adminOnly, (req, res)=>{
HomebrewModel.aggregate(junkBrewsPipeline).option({ maxTimeMS: 60000 }) HomebrewModel.aggregate(junkBrewsPipeline).option({ maxTimeMS: 60000 })
.then((objs)=>res.json({ count: objs.length, brewCollection : objs })) .then((objs)=>res.json({ count: objs.length, brewCollection : objs }))
@@ -77,7 +78,7 @@ export default function createAdminApi(vite) {
}); });
}); });
// Delete up to 300 brews that have not been viewed or updated in 30 days and are shorter than 140 bytes // Delete result of junkBrewsPipeline
router.post('/admin/cleanupJunk', mw.adminOnly, (req, res)=>{ router.post('/admin/cleanupJunk', mw.adminOnly, (req, res)=>{
HomebrewModel.aggregate(junkBrewsPipeline).option({ maxTimeMS: 60000 }) HomebrewModel.aggregate(junkBrewsPipeline).option({ maxTimeMS: 60000 })
.then((docs)=>{ .then((docs)=>{
@@ -91,7 +92,6 @@ export default function createAdminApi(vite) {
}); });
}); });
// Search for up to 300 unauthored brews that have not been viewed or updated in a year
router.get('/admin/cleanupLost', mw.adminOnly, (req, res)=>{ router.get('/admin/cleanupLost', mw.adminOnly, (req, res)=>{
HomebrewModel.aggregate(lostBrewsPipeline).option({ maxTimeMS: 60000 }) HomebrewModel.aggregate(lostBrewsPipeline).option({ maxTimeMS: 60000 })
.then((objs)=>res.json({ count: objs.length, brewCollection : objs })) .then((objs)=>res.json({ count: objs.length, brewCollection : objs }))
@@ -101,7 +101,7 @@ export default function createAdminApi(vite) {
}); });
}); });
// Delete up to 300 unauthored brews that have not been viewed or updated in a year // Delete result of lostBrewsPipeline
router.post('/admin/cleanupLost', mw.adminOnly, (req, res)=>{ router.post('/admin/cleanupLost', mw.adminOnly, (req, res)=>{
HomebrewModel.aggregate(lostBrewsPipeline).option({ maxTimeMS: 60000 }) HomebrewModel.aggregate(lostBrewsPipeline).option({ maxTimeMS: 60000 })
.then((docs)=>{ .then((docs)=>{