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({
|
const userSubmissions = await prisma.submission.findMany({
|
||||||
where: { userId: userId },
|
where: {
|
||||||
|
userId: userId,
|
||||||
|
problem: {
|
||||||
|
isPublished: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
include: {
|
include: {
|
||||||
problem: {
|
problem: {
|
||||||
select: {
|
select: {
|
||||||
|
|||||||
@ -130,16 +130,21 @@ export default async function DashboardPage() {
|
|||||||
// 学生统计
|
// 学生统计
|
||||||
const [
|
const [
|
||||||
totalProblems,
|
totalProblems,
|
||||||
completedProblems,
|
completedProblemRows,
|
||||||
totalSubmissions,
|
totalSubmissions,
|
||||||
recentSubmissions,
|
recentSubmissions,
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
prisma.problem.count({ where: { isPublished: true } }),
|
prisma.problem.count({ where: { isPublished: true } }),
|
||||||
prisma.submission.count({
|
prisma.submission.findMany({
|
||||||
where: {
|
where: {
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
status: "AC",
|
status: "AC",
|
||||||
|
problem: {
|
||||||
|
isPublished: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
distinct: ["problemId"],
|
||||||
|
select: { problemId: true },
|
||||||
}),
|
}),
|
||||||
prisma.submission.count({ where: { userId: user.id } }),
|
prisma.submission.count({ where: { userId: user.id } }),
|
||||||
prisma.submission.findMany({
|
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) => ({
|
recentActivity = recentSubmissions.map((sub) => ({
|
||||||
type: "我的提交",
|
type: "我的提交",
|
||||||
title: `题目 ${sub.problem.displayId}`,
|
title: `题目 ${sub.problem.displayId}`,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user