mirror of
https://github.com/cfngc4594/monaco-editor-lsp-next.git
synced 2026-05-31 10:18:52 +00:00
fix(student-dashboard): count completed problems uniquely
This commit is contained in:
parent
b2505eda46
commit
6764ca3416
@ -65,7 +65,12 @@ export async function getStudentDashboardData() {
|
||||
|
||||
// 获取当前学生的所有提交记录(包含题目英文标题)
|
||||
const userSubmissions = await prisma.submission.findMany({
|
||||
where: { userId: userId },
|
||||
where: {
|
||||
userId: userId,
|
||||
problem: {
|
||||
isPublished: true,
|
||||
},
|
||||
},
|
||||
include: {
|
||||
problem: {
|
||||
select: {
|
||||
|
||||
@ -130,16 +130,21 @@ export default async function DashboardPage() {
|
||||
// 学生统计
|
||||
const [
|
||||
totalProblems,
|
||||
completedProblems,
|
||||
completedProblemRows,
|
||||
totalSubmissions,
|
||||
recentSubmissions,
|
||||
] = await Promise.all([
|
||||
prisma.problem.count({ where: { isPublished: true } }),
|
||||
prisma.submission.count({
|
||||
prisma.submission.findMany({
|
||||
where: {
|
||||
userId: user.id,
|
||||
status: "AC",
|
||||
problem: {
|
||||
isPublished: true,
|
||||
},
|
||||
},
|
||||
distinct: ["problemId"],
|
||||
select: { problemId: true },
|
||||
}),
|
||||
prisma.submission.count({ where: { userId: user.id } }),
|
||||
prisma.submission.findMany({
|
||||
@ -160,7 +165,11 @@ export default async function DashboardPage() {
|
||||
}),
|
||||
]);
|
||||
|
||||
stats = { totalProblems, completedProblems, totalSubmissions };
|
||||
stats = {
|
||||
totalProblems,
|
||||
completedProblems: completedProblemRows.length,
|
||||
totalSubmissions,
|
||||
};
|
||||
recentActivity = recentSubmissions.map((sub) => ({
|
||||
type: "我的提交",
|
||||
title: `题目 ${sub.problem.displayId}`,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user