added chapter view, fixes, added ratings, added chapter updates/deletions

This commit is contained in:
lnn0q 2025-06-01 00:37:26 +03:00
parent 029b7e9353
commit 4801cf3a13
34 changed files with 1345 additions and 191 deletions

View file

@ -0,0 +1,26 @@
import { prisma } from '@app/server/prisma/client';
export async function updateBookStats(id: string) {
const bookWordsTotal = await prisma.bookChapter.aggregate({
where: {
bookId: id
},
_sum: {
wordsTotal: true
}
});
const chaptersTotal = await prisma.bookChapter.count({
where: {
bookId: id
}
});
return prisma.book.update({
where: { id },
data: {
wordsTotal: bookWordsTotal._sum.wordsTotal != null ? bookWordsTotal._sum.wordsTotal : 0,
chaptersTotal
}
});
}