import { db, PostType } from '@nice/common'; // 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 }, // }); // await db.post.update({ // where: { id: sectionId }, // data: { // // totalLectures: sectionStats._count._all, // // totalDuration: sectionStats._sum.duration || 0, // }, // }); // } // 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, // }, // }); // }