From 8cf217b7bb8bc23558f317a5db98b5e6f725ed9f Mon Sep 17 00:00:00 2001 From: fatchan Date: Sun, 25 Aug 2019 13:13:17 +0000 Subject: [PATCH] homepage fixes for dead board --- helpers/build.js | 7 ++++--- schedules.js | 1 + views/pages/home.pug | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/helpers/build.js b/helpers/build.js index 71ed0d7c..16198c7d 100644 --- a/helpers/build.js +++ b/helpers/build.js @@ -200,8 +200,9 @@ module.exports = { } } }); - const totalActiveUsers = activeUsers.totalActiveUsers[0].ips; - await Boards.db.bulkWrite(bulkWrites); + if (bulkWrites.length > 0) { + await Boards.db.bulkWrite(bulkWrites); + } const [ totalPosts, boards, fileStats ] = await Promise.all([ Boards.totalPosts(), //overall total posts ever made Boards.frontPageSortLimit(), //boards sorted by users, pph, total posts @@ -209,7 +210,7 @@ module.exports = { ]); const html = render('index.html', 'home.pug', { totalPosts: totalPosts, - totalActiveUsers, + activeUsers, boards, fileStats, }); diff --git a/schedules.js b/schedules.js index 52378c3d..557d8f32 100644 --- a/schedules.js +++ b/schedules.js @@ -16,6 +16,7 @@ const msTime = require(__dirname+'/helpers/mstime.js') console.log('Starting schedules'); +await buildHomepage(); setInterval(async () => { try { await buildHomepage(); diff --git a/views/pages/home.pug b/views/pages/home.pug index 2d2427dd..c99c2050 100644 --- a/views/pages/home.pug +++ b/views/pages/home.pug @@ -43,6 +43,7 @@ block content th Active Content tr td #{totalPosts} + - const totalActiveUsers = activeUsers.totalActiveUsers.length > 0 ? activeUsers.totalActiveUsers[0].ips : 0; td #{totalActiveUsers} td #{fileStats.totalSizeString} .table-container.flex-center.mv-10