[cards][admin] notify if the queue gets too long

This commit is contained in:
Andrea 2022-02-26 15:11:27 +01:00
parent 1cfa3ff101
commit 7566c592aa
2 changed files with 10 additions and 0 deletions

View File

@ -86,6 +86,11 @@ const templates = {
</p>
`,
},
cardsWarning: {
subject: 'Cards queue is getting long',
text: 'There\'s {{count}} cards in the queue!',
html: '<p>There\'s {{count}} cards in the queue!</p>',
}
}
const applyTemplate = (template, context, params) => {

View File

@ -1,4 +1,5 @@
const {decodeTime} = require('ulid');
const mailer = require('./mailer');
// TODO all the duplication...
const buildDict = (fn, ...args) => {
@ -113,5 +114,9 @@ module.exports.calculateStats = async (db, allLocales) => {
const cardsQueue = (await db.get(`SELECT count(*) as c FROM profiles WHERE card = '' OR cardDark = ''`)).c;
if (cardsQueue > 64) {
mailer('andrea@avris.it', 'cardsWarning', {count: cardsQueue});
}
return { calculatedAt: parseInt(new Date() / 1000), users, locales, cardsQueue };
}