mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-26 22:32:45 +00:00
Add lock count route, update pipelines
This commit is contained in:
@@ -27,10 +27,12 @@ const mw = {
|
||||
};
|
||||
|
||||
const junkBrewPipeline = [
|
||||
{ $match : {
|
||||
updatedAt : { $lt: Moment().subtract(30, 'days').toDate() },
|
||||
lastViewed : { $lt: Moment().subtract(30, 'days').toDate() }
|
||||
}},
|
||||
{ $match :
|
||||
{
|
||||
updatedAt : { $lt: Moment().subtract(30, 'days').toDate() },
|
||||
lastViewed : { $lt: Moment().subtract(30, 'days').toDate() }
|
||||
}
|
||||
},
|
||||
{ $project: { textBinSize: { $binarySize: '$textBin' } } },
|
||||
{ $match: { textBinSize: { $lt: 140 } } },
|
||||
{ $limit: 100 }
|
||||
@@ -138,6 +140,31 @@ router.get('/admin/stats', mw.adminOnly, async (req, res)=>{
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/admin/lock', mw.adminOnly, async (req, res)=>{
|
||||
try {
|
||||
const countLocksPipeline = [
|
||||
{
|
||||
$match :
|
||||
{
|
||||
'lock.locked' : true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$count :
|
||||
'count',
|
||||
}
|
||||
];
|
||||
const totalLockCount = await HomebrewModel.getAggregate(countLocksPipeline);
|
||||
const count = totalLockCount[0].count;
|
||||
return res.json({
|
||||
count
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return res.status(500).json({ error: 'Unable to get lock count' });
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/admin', mw.adminOnly, (req, res)=>{
|
||||
templateFn('admin', {
|
||||
url : req.originalUrl
|
||||
|
||||
Reference in New Issue
Block a user