Merge branch 'patch-hotThreads' into 'hot-threads'

add hotThreads function from ptchina, needs some more work :)

See merge request fatchan/jschan!250
indiachan-spamvector
Thomas Lynch 2 years ago
commit 81d4d7c8f0
  1. 4
      lib/build/tasks.js
  2. 15
      views/pages/home.pug

@ -246,11 +246,12 @@ module.exports = {
const { maxRecentNews } = config.get;
const label = '/index.html';
const start = process.hrtime();
let [ totalStats, boards, fileStats, recentNews ] = await Promise.all([
let [ totalStats, boards, fileStats, recentNews, hotThreads ] = await Promise.all([
Boards.totalStats(), //overall total posts ever made
Boards.boardSort(0, 20), //top 20 boards sorted by users, pph, total posts
Files.activeContent(), //size and number of files
News.find(maxRecentNews), //some recent newsposts
Posts.db.find({'board': {$in: listedBoards}, 'thread': null, 'date': {$gte: (new Date(Date.now() - (7 * 24 * 60 * 60 * 1000)))}}).sort({'replyposts':-1}).limit(5).toArray(), //top 5 threads last 7 days
]);
const [ localStats, webringStats ] = totalStats;
const { html } = await render('index.html', 'home.pug', {
@ -259,6 +260,7 @@ module.exports = {
boards,
fileStats,
recentNews,
hotThreads,
});
const end = process.hrtime(start);
debugLogs && console.log(timeDiffString(label, end));

@ -28,7 +28,22 @@ block content
td
- const newsDate = new Date(post.date);
time.right.reltime(datetime=newsDate.toISOString()) #{newsDate.toLocaleString(undefined, {hourCycle:'h23'})}
if hotThreads && hotThreads.length > 0
.table-container.flex-center.mv-5
table.posttable
tr(colspan=3)
each post in hotThreads
tr
td 🔥#{post.replyposts + post.replyfiles}
td
if post.nomarkup != null
a.quote(href=`/${post.board}/thread/${post.postId}.html#${post.postId}`) #{`${post.subject.substring(0,30)}${post.subject && post.subject.length > 30 ? '...' : ''} ${post.nomarkup && post.nomarkup.substring(0,50)}${post.nomarkup && post.nomarkup.length > 50 ? '...' : ''}`}
if post.nomarkup === null
a.quote(href=`/${post.board}/thread/${post.postId}.html#${post.postId}`) (No comment.)
td
- const newsDate = new Date(post.bumped);
time.right.reltime(datetime=newsDate.toISOString()) #{newsDate.toLocaleString(undefined, {hourCycle:'h23'})}
if boards && boards.length > 0
+boardtable(true, false)
each board in boards

Loading…
Cancel
Save