feat: reset views & monthViews

This commit is contained in:
2026-01-13 12:23:58 +01:00
parent 29c19bb34a
commit 01888f2c52
4 changed files with 48 additions and 3 deletions
+4
View File
@@ -57,6 +57,9 @@ exports.onProjectWritten = onDocumentWritten('projects/{projectId}', async (proj
.doc(projectId)
.collection('monthlyListens')
.doc(monthKey)
const projectsRef = refList.projects.doc(projectId)
const totalsDocRef = refList.projectStreamStatsMonthlyTotals.doc(monthKey)
await db.runTransaction(async (transaction) => {
@@ -78,6 +81,7 @@ exports.onProjectWritten = onDocumentWritten('projects/{projectId}', async (proj
}
transaction.set(statsDocRef, updatePayload, { merge: true })
transaction.set(projectsRef, { monthViews: FieldValue.increment(delta) }, { merge: true })
const totalsUpdatePayload = {
monthKey,