collect-system/apps/server/src/models/lecture/utils.ts

49 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-02-06 16:32:52 +08:00
import { db, PostType } from '@nice/common';
2025-01-03 09:24:46 +08:00
2025-02-06 16:32:52 +08:00
// export async function updateSectionLectureStats(sectionId: string) {
// const sectionStats = await db.post.aggregate({
// where: {
// parentId: sectionId,
// deletedAt: null,
// type: PostType.LECTURE,
// },
// _count: { _all: true },
// _sum: { duration: true },
// });
2025-01-03 09:24:46 +08:00
2025-02-06 16:32:52 +08:00
// await db.post.update({
// where: { id: sectionId },
// data: {
// // totalLectures: sectionStats._count._all,
// // totalDuration: sectionStats._sum.duration || 0,
// },
// });
// }
2025-01-03 09:24:46 +08:00
2025-02-06 16:32:52 +08:00
// export async function updateParentLectureStats(parentId: string) {
// const ParentStats = await db.post.aggregate({
// where: {
// ancestors: {
// some: {
// ancestorId: parentId,
// descendant: {
// type: PostType.LECTURE,
// deletedAt: null,
// },
// },
// },
// },
// _count: { _all: true },
// _sum: {
// duration: true,
// },
// });
// await db.post.update({
// where: { id: parentId },
// data: {
// //totalLectures: courseStats._count._all,
// //totalDuration: courseStats._sum.duration || 0,
// },
// });
// }