feat: reset views & monthViews
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user