mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #2776 from overleaf/spd-count-files
Add script to count files and docs in projects GitOrigin-RevId: 8d5e80ee9d48912d07c0f4ed61398b1a3f1ac0f5
This commit is contained in:
parent
e45c9d6c10
commit
130d21b122
1 changed files with 35 additions and 0 deletions
35
services/web/scripts/count_files_in_projects.js
Normal file
35
services/web/scripts/count_files_in_projects.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
const readline = require('readline')
|
||||
const ProjectEntityHandler = require('../app/src/Features/Project/ProjectEntityHandler')
|
||||
const ProjectGetter = require('../app/src/Features/Project/ProjectGetter')
|
||||
const Errors = require('../app/src/Features/Errors/Errors')
|
||||
|
||||
async function countFiles() {
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin
|
||||
})
|
||||
|
||||
for await (const projectId of rl) {
|
||||
try {
|
||||
const project = await ProjectGetter.promises.getProject(projectId)
|
||||
const {
|
||||
files,
|
||||
docs
|
||||
} = await ProjectEntityHandler.promises.getAllEntitiesFromProject(project)
|
||||
console.error(
|
||||
projectId,
|
||||
files.length,
|
||||
project.deletedFiles.length,
|
||||
docs.length,
|
||||
project.deletedDocs.length
|
||||
)
|
||||
} catch (err) {
|
||||
if (err instanceof Errors.NotFoundError) {
|
||||
console.error(projectId, 'NOTFOUND')
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
countFiles().then(() => process.exit(0))
|
Loading…
Reference in a new issue