mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-28 22:23:17 -05:00
Merge pull request #9795 from overleaf/msm-audit-log-migration-fix
[web/scripts] Fix audit log migration script GitOrigin-RevId: 55c90520240bef92a4be1925809cac178c8b3ee9
This commit is contained in:
parent
1549bac91a
commit
aefcf3c8bc
1 changed files with 22 additions and 0 deletions
|
@ -44,6 +44,18 @@ async function main(options) {
|
||||||
},
|
},
|
||||||
{ _id: 1, auditLog: 1 }
|
{ _id: 1, auditLog: 1 }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// most projects are processed after its owner has been processed, but only those
|
||||||
|
// users with an existing `auditLog` have been taken into consideration, leaving
|
||||||
|
// some projects orphan. This batched update processes all remaining projects.
|
||||||
|
await batchedUpdate(
|
||||||
|
'projects',
|
||||||
|
{ auditLog: { $exists: true } },
|
||||||
|
async (x, projects) => {
|
||||||
|
await processProjectsBatch(projects, options)
|
||||||
|
},
|
||||||
|
{ _id: 1, auditLog: 1 }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +82,16 @@ async function processUser(user, options) {
|
||||||
projects.forEach(project => processProject(project, options))
|
projects.forEach(project => processProject(project, options))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function processProjectsBatch(projects, options) {
|
||||||
|
await promiseMapWithLimit(
|
||||||
|
options.writeConcurrency,
|
||||||
|
projects,
|
||||||
|
async project => {
|
||||||
|
await processProject(project, options)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
async function processProject(project, options) {
|
async function processProject(project, options) {
|
||||||
const entries = project.auditLog.map(log => ({
|
const entries = project.auditLog.map(log => ({
|
||||||
...log,
|
...log,
|
||||||
|
|
Loading…
Reference in a new issue