mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2025-07-25 11:00:07 +02:00

RPO can now be scaled to allow a little extra grace in certain circumstances. Co-authored-by: Brian Gough <brian.gough@overleaf.com> GitOrigin-RevId: fa60a9ffe966977e396b5645919ddd1451fb1b7a
33 lines
927 B
JavaScript
33 lines
927 B
JavaScript
import Metrics from '@overleaf/metrics'
|
|
import { objectIdFromDate } from './utils.mjs'
|
|
import { db } from '../storage/lib/mongodb.js'
|
|
|
|
const projectsCollection = db.collection('projects')
|
|
|
|
/**
|
|
*
|
|
* @param {Date} beforeTime
|
|
* @return {Promise<void>}
|
|
*/
|
|
export async function measurePendingChangesBeforeTime(beforeTime) {
|
|
const pendingChangeCount = await projectsCollection.countDocuments({
|
|
'overleaf.backup.pendingChangeAt': {
|
|
$lt: beforeTime,
|
|
},
|
|
})
|
|
|
|
Metrics.gauge('backup_verification_pending_changes', pendingChangeCount)
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param {Date} graceTime
|
|
* @return {Promise<void>}
|
|
*/
|
|
export async function measureNeverBackedUpProjects(graceTime) {
|
|
const neverBackedUpCount = await projectsCollection.countDocuments({
|
|
'overleaf.backup.lastBackedUpVersion': null,
|
|
_id: { $lt: objectIdFromDate(graceTime) },
|
|
})
|
|
Metrics.gauge('backup_verification_never_backed_up', neverBackedUpCount)
|
|
}
|