[doc-updater] add mongo logging to project notifications cron (#35421)

GitOrigin-RevId: db8a84f2079c57b5d5f1ae5447f8526dfb0a6d67
This commit is contained in:
Kristina
2026-09-17 11:25:37 +00:00
committed by Copybot
parent 6fd593ff86
commit 7fe05140b0
@@ -104,6 +104,9 @@ async function main() {
console.log(
`Collaborator lookups: cacheHitWithCollaborators=${stats.collaboratorCacheHitWithCollaborators}, cacheHitNoCollaborators=${stats.collaboratorCacheHitNoCollaborators}, cacheMissWithCollaborators=${stats.collaboratorCacheMissWithCollaborators}, cacheMissNoCollaborators=${stats.collaboratorCacheMissNoCollaborators}, mongoQueries=${stats.collaboratorMongoQueries}`
)
console.log(
`mongo-queries: ${formatDuration(stats.collaboratorMongoQueriesMs)} mongo_queries_ms=${stats.collaboratorMongoQueriesMs}`
)
if (dryRun) {
console.log('\n[DRY RUN] Projects that would be queued:')
@@ -234,6 +237,7 @@ async function getProjectsWithCollaborators(
batches.push(projectsNeedingMongoLookup.slice(i, i + MONGO_IN_BATCH_SIZE))
}
const mongoQueriesStart = performance.now()
const batchResults = await promiseMapWithLimit(
MONGO_BATCH_CONCURRENCY,
batches,
@@ -256,6 +260,9 @@ async function getProjectsWithCollaborators(
.toArray()
}
)
stats.collaboratorMongoQueriesMs += Math.round(
performance.now() - mongoQueriesStart
)
const positives = new Set(
batchResults.flatMap(docs => docs.map(d => d._id.toString()))
@@ -294,6 +301,7 @@ type NotificationStats = {
collaboratorCacheMissWithCollaborators: number
collaboratorCacheMissNoCollaborators: number
collaboratorMongoQueries: number
collaboratorMongoQueriesMs: number
}
async function getProjectsToNotify(): Promise<{
@@ -317,6 +325,7 @@ async function getProjectsToNotify(): Promise<{
collaboratorCacheMissWithCollaborators: 0,
collaboratorCacheMissNoCollaborators: 0,
collaboratorMongoQueries: 0,
collaboratorMongoQueriesMs: 0,
}
let lastProgressLog = Date.now()