feat(admin): add pending tag suggestions detector

This commit is contained in:
Jennie Robinson Faber 2026-04-08 11:12:52 +01:00
parent ab3f0a8b39
commit 0dc1b6ddbc
2 changed files with 72 additions and 0 deletions

View file

@ -226,4 +226,35 @@ export async function detectEventsNearCapacity() {
}
}
export async function detectPendingTagSuggestions() {
await connectDB()
const suggestions = await TagSuggestion
.find({ status: 'pending' })
.select('_id')
.lean()
if (suggestions.length === 0) {
return {
type: 'tag_suggestions_pending',
severity: 'attention',
title: 'Pending tag suggestions',
items: []
}
}
return {
type: 'tag_suggestions_pending',
severity: 'attention',
title: 'Pending tag suggestions',
items: [
{
id: 'tag-suggestions',
label: `${suggestions.length} pending tag suggestion${suggestions.length === 1 ? '' : 's'}`,
sublabel: 'Review and approve in Tags',
href: '/admin/tags'
}
],
// signature is computed from the underlying suggestion ids, not the rendered item id
signatureIds: suggestions.map((s) => String(s._id))
}
}
// Aggregator lands in task 8.