mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-08 03:12:40 +00:00
Add lock count route, update pipelines
This commit is contained in:
@@ -27,10 +27,12 @@ const mw = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const junkBrewPipeline = [
|
const junkBrewPipeline = [
|
||||||
{ $match : {
|
{ $match :
|
||||||
updatedAt : { $lt: Moment().subtract(30, 'days').toDate() },
|
{
|
||||||
lastViewed : { $lt: Moment().subtract(30, 'days').toDate() }
|
updatedAt : { $lt: Moment().subtract(30, 'days').toDate() },
|
||||||
}},
|
lastViewed : { $lt: Moment().subtract(30, 'days').toDate() }
|
||||||
|
}
|
||||||
|
},
|
||||||
{ $project: { textBinSize: { $binarySize: '$textBin' } } },
|
{ $project: { textBinSize: { $binarySize: '$textBin' } } },
|
||||||
{ $match: { textBinSize: { $lt: 140 } } },
|
{ $match: { textBinSize: { $lt: 140 } } },
|
||||||
{ $limit: 100 }
|
{ $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)=>{
|
router.get('/admin', mw.adminOnly, (req, res)=>{
|
||||||
templateFn('admin', {
|
templateFn('admin', {
|
||||||
url : req.originalUrl
|
url : req.originalUrl
|
||||||
|
|||||||
Reference in New Issue
Block a user