fix count
All checks were successful
fetch npm modules / f0ck the f0cker (push) Successful in 19s

This commit is contained in:
Flummi 2023-07-02 13:22:19 +02:00
parent 9ca17e6fd4
commit 1380e45794
2 changed files with 14 additions and 8 deletions

View File

@ -44,14 +44,24 @@ export default (router, tpl) => {
session: !!req.session session: !!req.session
}); });
if('items' in f0cks) const count = {
f0cks: 0,
favs: 0
};
if('items' in f0cks) {
count.f0cks = f0cks.items.length;
f0cks.items = f0cks.items.slice(0, 50); f0cks.items = f0cks.items.slice(0, 50);
if('items' in favs) }
if('items' in favs) {
count.favs = favs.items.length;
favs.items = favs.items.slice(0, 50); favs.items = favs.items.slice(0, 50);
}
const data = { const data = {
user: query[0], user: query[0],
f0cks, f0cks,
count,
favs, favs,
tmp: null tmp: null
}; };

View File

@ -2,12 +2,8 @@
<div id="main"> <div id="main">
<h1>{{ user.user }}@if(user.avatar)&nbsp;<a href="/{{ user.avatar }}"><img src="/t/{{ user.avatar }}.webp" style="width: 24px" /></a>@endif</h1> <h1>{{ user.user }}@if(user.avatar)&nbsp;<a href="/{{ user.avatar }}"><img src="/t/{{ user.avatar }}.webp" style="width: 24px" /></a>@endif</h1>
<p>ID: {{ user.user_id }}</p> <p>ID: {{ user.user_id }}</p>
@if('items' in f0cks) <p>{{ count.f0cks }} f0ck{{ count.f0cks == 1 ? '' : 's' }}</p>
<p>{{ f0cks.items.length }} f0ck{{ f0cks.items.length == 1 ? '' : 's' }}</p> <p>{{ count.favs }} fav{{ count.favs == 1 ? '' : 's' }}</p>
@endif
@if('items' in favs)
<p>{{ favs.items.length }} fav{{ favs.items.length == 1 ? '' : 's' }}</p>
@endif
<p>Joined: {{ user.created_at }}</p> <p>Joined: {{ user.created_at }}</p>
<h2>f0cks:</h2> <h2>f0cks:</h2>