[cards][admin] notify if the queue gets too long
This commit is contained in:
parent
1cfa3ff101
commit
7566c592aa
|
@ -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) => {
|
||||
|
|
|
@ -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 };
|
||||
}
|
||||
|
|
Reference in New Issue