This commit is contained in:
ditiqi 2025-01-27 22:43:22 +08:00
parent a47401971e
commit 18d9b5e33c
1 changed files with 32 additions and 32 deletions

View File

@ -1,21 +1,21 @@
import { db, Lecture } from "@nice/common"
import { db, Lecture } from '@nice/common';
export async function updateSectionLectureStats(sectionId: string) {
const sectionStats = await db.lecture.aggregate({
where: {
sectionId,
deletedAt: null
deletedAt: null,
},
_count: { _all: true },
_sum: { duration: true }
_sum: { duration: true },
});
await db.section.update({
where: { id: sectionId },
data: {
totalLectures: sectionStats._count._all,
totalDuration: sectionStats._sum.duration || 0
}
// totalLectures: sectionStats._count._all,
// totalDuration: sectionStats._sum.duration || 0,
},
});
}
@ -23,17 +23,17 @@ export async function updateCourseLectureStats(courseId: string) {
const courseStats = await db.lecture.aggregate({
where: {
courseId,
deletedAt: null
deletedAt: null,
},
_count: { _all: true },
_sum: { duration: true }
_sum: { duration: true },
});
await db.course.update({
where: { id: courseId },
data: {
totalLectures: courseStats._count._all,
totalDuration: courseStats._sum.duration || 0
}
//totalLectures: courseStats._count._all,
//totalDuration: courseStats._sum.duration || 0,
},
});
}