mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-29 12:01:32 +02:00
Add support for --any-comments to check_docs script (#26903)
GitOrigin-RevId: 283e761a3f305286584164b12e9736deba0064d9
This commit is contained in:
committed by
Copybot
parent
5ed1225162
commit
b2fb70c2b6
@@ -16,7 +16,7 @@ const OPTS = parseArgs()
|
||||
function parseArgs() {
|
||||
const args = minimist(process.argv.slice(2), {
|
||||
string: ['min-project-id', 'max-project-id', 'project-modified-since'],
|
||||
boolean: ['help', 'dangling-comments', 'tracked-changes'],
|
||||
boolean: ['help', 'dangling-comments', 'tracked-changes', 'any-comments'],
|
||||
})
|
||||
|
||||
if (args.help) {
|
||||
@@ -26,9 +26,10 @@ function parseArgs() {
|
||||
|
||||
const danglingComments = Boolean(args['dangling-comments'])
|
||||
const trackedChanges = Boolean(args['tracked-changes'])
|
||||
if (!danglingComments && !trackedChanges) {
|
||||
const anyComments = Boolean(args['any-comments'])
|
||||
if (!danglingComments && !trackedChanges && !anyComments) {
|
||||
console.log(
|
||||
'At least one of --dangling-comments or --tracked-changes must be enabled'
|
||||
'At least one of --dangling-comments, --tracked-changes, or --any-comments must be enabled'
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
||||
@@ -41,6 +42,7 @@ function parseArgs() {
|
||||
: null,
|
||||
danglingComments,
|
||||
trackedChanges,
|
||||
anyComments,
|
||||
concurrency: parseInt(args.concurrency ?? '1', 10),
|
||||
}
|
||||
}
|
||||
@@ -56,6 +58,7 @@ Options:
|
||||
Example: 2020-01-01
|
||||
--dangling-comments Report projects with dangling comments
|
||||
--tracked-changes Report projects with tracked changes
|
||||
--any-comments Report projects with any comments
|
||||
--concurrency How many projects can be processed in parallel
|
||||
`)
|
||||
}
|
||||
@@ -65,6 +68,8 @@ async function main() {
|
||||
let projectsProcessed = 0
|
||||
let danglingCommentsFound = 0
|
||||
let trackedChangesFound = 0
|
||||
let anyCommentsFound = 0
|
||||
|
||||
for await (const projectId of getProjectIds()) {
|
||||
await queue.onEmpty()
|
||||
queue.add(async () => {
|
||||
@@ -87,6 +92,13 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
if (OPTS.anyComments) {
|
||||
if (docsHaveAnyComments(docs)) {
|
||||
console.log(`Project ${projectId} has comments`)
|
||||
anyCommentsFound += 1
|
||||
}
|
||||
}
|
||||
|
||||
projectsProcessed += 1
|
||||
if (projectsProcessed % 100000 === 0) {
|
||||
console.log(
|
||||
@@ -106,6 +118,10 @@ async function main() {
|
||||
if (OPTS.trackedChanges) {
|
||||
console.log(`${trackedChangesFound} projects with tracked changes found`)
|
||||
}
|
||||
|
||||
if (OPTS.anyComments) {
|
||||
console.log(`${anyCommentsFound} projects with any comments found`)
|
||||
}
|
||||
}
|
||||
|
||||
function getProjectIds() {
|
||||
@@ -213,6 +229,16 @@ function docsHaveTrackedChanges(docs) {
|
||||
return false
|
||||
}
|
||||
|
||||
function docsHaveAnyComments(docs) {
|
||||
for (const doc of docs) {
|
||||
const comments = doc.ranges?.comments ?? []
|
||||
if (comments.length > 0) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
await scriptRunner(main)
|
||||
process.exit(0)
|
||||
|
||||
Reference in New Issue
Block a user