core: show dcnt and scnt

pull/241/head
undefined 3 years ago
parent e44c627a83
commit 3487ba3441

@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.39.29", "version": "2.39.30",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "src/loader", "main": "src/loader",
"module": "src/loader", "module": "src/loader",

@ -17,6 +17,7 @@ import paginate from '../lib/paginate';
import { isPid, parsePid as convertPid } from '../lib/validator'; import { isPid, parsePid as convertPid } from '../lib/validator';
import { PERM, PRIV } from '../model/builtin'; import { PERM, PRIV } from '../model/builtin';
import * as contest from '../model/contest'; import * as contest from '../model/contest';
import * as discussion from '../model/discussion';
import domain from '../model/domain'; import domain from '../model/domain';
import problem from '../model/problem'; import problem from '../model/problem';
import record from '../model/record'; import record from '../model/record';
@ -223,11 +224,17 @@ export class ProblemDetailHandler extends ProblemHandler {
problem.getStatus(domainId, this.pdoc.docId, this.user._id), problem.getStatus(domainId, this.pdoc.docId, this.user._id),
user.getById(domainId, this.pdoc.owner), user.getById(domainId, this.pdoc.owner),
]); ]);
const [scnt, dcnt] = await Promise.all([
solution.count(domainId, { parentId: this.pdoc.docId }),
discussion.count(domainId, { parentId: this.pdoc.docId }),
]);
this.response.body = { this.response.body = {
pdoc: this.pdoc, pdoc: this.pdoc,
udoc: this.udoc, udoc: this.udoc,
psdoc: this.psdoc, psdoc: this.psdoc,
title: this.pdoc.title, title: this.pdoc.title,
solutionCount: scnt,
discussionCount: dcnt,
}; };
this.extraTitleContent = this.pdoc.title; this.extraTitleContent = this.pdoc.title;
} }

@ -1,6 +1,6 @@
{ {
"name": "@hydrooj/ui-default", "name": "@hydrooj/ui-default",
"version": "4.25.9", "version": "4.25.10",
"author": "undefined <i@undefined.moe>", "author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"main": "hydro.js", "main": "hydro.js",

@ -5,7 +5,7 @@ import { ConfirmDialog } from 'vj/components/dialog';
const page = new NamedPage([ const page = new NamedPage([
'problem_create', 'problem_edit', 'problem_solution', 'problem_submit', 'problem_create', 'problem_edit', 'problem_solution', 'problem_submit',
'problem_files', 'discussion_node', 'discussion_detail', 'problem_files', 'problem_detail', 'discussion_node', 'discussion_detail',
], () => { ], () => {
$(document).on('click', '[name="problem-sidebar__show-category"]', (ev) => { $(document).on('click', '[name="problem-sidebar__show-category"]', (ev) => {
$(ev.currentTarget).hide(); $(ev.currentTarget).hide();

@ -67,12 +67,12 @@
{% endif %} {% endif %}
{% if handler.user.hasPerm(perm.PERM_VIEW_DISCUSSION) %} {% if handler.user.hasPerm(perm.PERM_VIEW_DISCUSSION) %}
<li class="menu__item"><a class="menu__link{% if page_name == 'discussion_node' or page_name == 'discussion_detail' %} active{% endif %}" href="{{ url('discussion_node', type='problem', name=pdoc.docId) }}"> <li class="menu__item"><a class="menu__link{% if page_name == 'discussion_node' or page_name == 'discussion_detail' %} active{% endif %}" href="{{ url('discussion_node', type='problem', name=pdoc.docId) }}">
<span class="icon icon-comment--text"></span> {{ _('Discussions') }} <span class="icon icon-comment--text"></span> {{ _('Discussions') }}{% if discussionCount !== undefined %} ({{ discussionCount }}){% endif %}
</a></li> </a></li>
{% endif %} {% endif %}
{% if handler.user.hasPerm(perm.PERM_VIEW_PROBLEM_SOLUTION) %} {% if handler.user.hasPerm(perm.PERM_VIEW_PROBLEM_SOLUTION) %}
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_solution' %} active{% endif %}" href="{{ url('problem_solution', pid=pdoc.pid|default(pdoc.docId)) }}"> <li class="menu__item"><a class="menu__link{% if page_name == 'problem_solution' %} active{% endif %}" href="{{ url('problem_solution', pid=pdoc.pid|default(pdoc.docId)) }}">
<span class="icon icon-comment--text"></span> {{ _('Solutions') }} <span class="icon icon-comment--text"></span> {{ _('Solutions') }}{% if solutionCount !== undefined %} ({{ solutionCount }}){% endif %}
</a></li> </a></li>
{% endif %} {% endif %}
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_files' %} active{% endif %}" href="{{ url('problem_files', pid=pdoc.pid|default(pdoc.docId)) }}"> <li class="menu__item"><a class="menu__link{% if page_name == 'problem_files' %} active{% endif %}" href="{{ url('problem_files', pid=pdoc.pid|default(pdoc.docId)) }}">

Loading…
Cancel
Save