Some changes to allow ppd display on board list pages, its a more useful stat for low activity sites. cant sort py ppd yet

merge-requests/208/head
Thomas Lynch 4 years ago
parent 270e0f289c
commit bd99a7e267
  1. 5
      db/boards.js
  2. 83
      db/stats.js
  3. 10
      gulp/res/css/style.css
  4. 8
      views/includes/boardtable.pug
  5. 9
      views/includes/webringboardtable.pug
  6. 14
      views/mixins/boardtable.pug
  7. 6
      views/pages/boardlist.pug
  8. 4
      views/pages/globalmanageboardlist.pug
  9. 7
      views/pages/home.pug

@ -155,6 +155,7 @@ module.exports = {
'lastPostTimestamp': 1,
'sequence_value': 1,
'pph': 1,
'ppd': 1,
'ips': 1,
'settings.sfw': 1,
'settings.description': 1,
@ -200,6 +201,7 @@ module.exports = {
'lastPostTimestamp': 1,
'sequence_value': 1,
'pph': 1,
//'ppd': 1,
'ips': 1,
'settings.sfw': 1,
'settings.description': 1,
@ -245,6 +247,9 @@ module.exports = {
'pph': {
'$sum': '$pph'
},
'ppd': {
'$sum': '$ppd'
},
'total': {
'$sum': 1
},

@ -39,34 +39,55 @@ module.exports = {
},
updateBoards: () => {
//todo: improve this query
return db.aggregate([{
'$unwind': {
'path': '$ips',
'preserveNullAndEmptyArrays': true
}
}, {
'$group': {
'_id': '$board',
'pph': {
'$max': '$pph' //use max since only one will have a value until we do a multi facet system that can $merge (dunno if even possible)
},
'ips': {
'$addToSet': '$ips'
}
}
}, {
'$project': {
'ips': {
'$size': '$ips'
},
'pph': 1
}
}, {
'$merge': {
'into': 'boards'
}
}]).toArray();
return db.aggregate([
{
'$unwind': {
'path': '$ips',
'preserveNullAndEmptyArrays': true
}
}, {
'$group': {
'_id': '$board',
'ppd': {
'$sum': '$pph'
},
'pph': {
'$push': { hour: '$hour', pph: '$pph' },
},
'ips': {
'$addToSet': '$ips'
}
}
}, {
'$project': {
'ips': {
'$size': '$ips'
},
'ppd': 1,
'pph': {
$first: {
$filter: {
input: '$pph',
as: 'hr',
cond: {
$eq: [ '$$hr.hour', (new Date().getHours()||24)-1 ]
},
}
}
}
}
}, {
'$project': {
'ips': 1,
'ppd': 1,
'pph': '$pph.pph'
}
}, {
'$merge': {
'into': 'boards'
}
}
]).toArray();
},
//reset stats, used at start of each hour
@ -77,12 +98,8 @@ module.exports = {
}, {
'$set': {
'ips': [],
}
}),
db.updateMany({}, {
'$set': {
'pph': 0,
'tph': 0
'tph': 0,
}
}),
]);

@ -1172,15 +1172,16 @@ tr:nth-child(odd) {
table.boardtable td:nth-child(3), table.boardtable th:nth-child(3),
table.boardtable td:nth-child(4), table.boardtable th:nth-child(4),
table.boardtable td:nth-child(5), table.boardtable th:nth-child(5) {
table.boardtable td:nth-child(5), table.boardtable th:nth-child(5),
table.boardtable td:nth-child(6), table.boardtable th:nth-child(6) {
word-break: keep-all;
overflow-wrap: break-word;
}
table.boardtable th:nth-child(6) {
table.boardtable.w900 th:last-child {
min-width: 100px;
}
table.boardtable td:nth-child(6) {
table.boardtable.w900 td:last-child {
text-shadow: #000 0px 0px 1px, #000 0px 0px 1px, #000 0px 0px 1px, #000 0px 0px 1px, #000 0px 0px 1px, #000 0px 0px 1px;
color: white;
}
@ -1330,7 +1331,8 @@ row.wrap.sb .col {
table.boardtable td:nth-child(3), table.boardtable th:nth-child(3),
table.boardtable td:nth-child(4), table.boardtable th:nth-child(4),
table.boardtable td:nth-child(5), table.boardtable th:nth-child(5),
table.boardtable td:nth-child(6), table.boardtable th:nth-child(6) {
table.boardtable td:nth-child(6), table.boardtable th:nth-child(6),
table.boardtable td:nth-child(7), table.boardtable th:nth-child(7) {
display: none;
}

@ -1,8 +0,0 @@
.table-container.flex-center.mv-10.text-center
table.boardtable
tr
th Board
th Description
th PPH
th Users
th Posts

@ -1,9 +0,0 @@
.table-container.flex-center.mv-10.text-center
table.boardtable.w900
tr
th Board
th Description
th PPH
th Users
th Posts
th Last Activity

@ -0,0 +1,14 @@
mixin boardtable(ppd=false, activity=false)
.table-container.flex-center.mv-10.text-center
table(class=`boardtable${activity ? ' w900' : ''}`)
tr
th Board
th Description
th PPH
if ppd
th PPD
th Users
th Posts
if activity
th Last Activity
block

@ -1,4 +1,5 @@
extends ../layout.pug
include ../mixins/boardtable.pug
block head
title Board List
@ -24,7 +25,7 @@ block content
input(type='submit', value='Filter')
if localBoards && localBoards.length > 0
h4.board-description Local Boards
include ../includes/webringboardtable.pug
+boardtable(true, true)
each board in localBoards
tr
td
@ -38,6 +39,7 @@ block content
a(href=`/${board._id}/index.html`) /#{board._id}/ - #{board.settings.name}
td #{board.settings.description}
td #{board.pph}
td #{board.ppd}
td #{board.ips}
td #{board.sequence_value-1}
if board.lastPostTimestamp
@ -46,7 +48,7 @@ block content
td -
if webringBoards && webringBoards.length > 0
h4.board-description Webring Boards
include ../includes/webringboardtable.pug
+boardtable(false, true)
each board in webringBoards
tr
td

@ -1,6 +1,7 @@
extends ../layout.pug
include ../mixins/ban.pug
include ../mixins/globalmanagenav.pug
include ../mixins/boardtable.pug
block head
title Manage
@ -42,7 +43,7 @@ block content
input(type='submit', value='Filter')
if localBoards && localBoards.length > 0
h4.text-center.mv-10 Board List:
include ../includes/webringboardtable.pug
+boardtable(true, true)
each board in localBoards
tr
td
@ -59,6 +60,7 @@ block content
a(href=`/${board._id}/index.html`) /#{board._id}/ - #{board.settings.name}
td #{board.settings.description}
td #{board.pph}
td #{board.ppd}
td #{board.ips}
td #{board.sequence_value-1}
if board.lastPostTimestamp

@ -1,4 +1,5 @@
extends ../layout.pug
include ../mixins/boardtable.pug
block head
title #{meta.siteName}
@ -29,7 +30,7 @@ block content
time.right.reltime(datetime=newsDate.toISOString()) #{newsDate.toLocaleString(undefined, {hourCycle:'h23'})}
if boards && boards.length > 0
include ../includes/boardtable.pug
+boardtable(true, false)
each board in boards
tr
td
@ -40,6 +41,7 @@ block content
a(href=`/${board._id}/index.html`) /#{board._id}/ - #{board.settings.name}
td #{board.settings.description}
td #{board.pph}
td #{board.ppd}
td #{board.ips}
td #{board.sequence_value-1}
if totalStats.total-totalStats.unlisted > boards.length
@ -53,6 +55,5 @@ block content
tr
td
pre.no-m-p
| There are currently #[span.bold #{totalStats.total-totalStats.unlisted}] public boards, #[span.bold #{totalStats.total}] in total.
| Sitewide, #[span.bold #{totalStats.pph}] post#{totalStats.pph === 1 ? ' has' : 's have'} been made in the last hour, #[span.bold #{totalStats.posts}] in total.
| There are currently #[span.bold #{totalStats.total-totalStats.unlisted}] public boards, #[span.bold #{totalStats.total}] in total. Sitewide, #[span.bold #{totalStats.ppd}] post#{totalStats.ppd === 1 ? ' has' : 's have'} been made in the last day, #[span.bold #{totalStats.pph}] in the last hour, #[span.bold #{totalStats.posts}] in total.
| #[span.bold #{fileStats.count}] file#{fileStats.count === 1 ? ' is' : 's are'} being served, totaling #[span.bold #{fileStats.totalSizeString}].

Loading…
Cancel
Save