mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Added clear questions api
This commit is contained in:
parent
a8d4a35eb8
commit
f651536354
2 changed files with 83 additions and 3 deletions
|
@ -41,7 +41,30 @@ const globalLog = './duplicateRemovingLog/log'
|
|||
utils.CreatePath(logPath)
|
||||
utils.WriteFile('', globalLog)
|
||||
|
||||
const params = process.argv.splice(2)
|
||||
// ----------------------------------------------
|
||||
let currentMaxIndex = -1
|
||||
let currentIndex = -1
|
||||
process.on('message', function () {
|
||||
process.send({
|
||||
currentMaxIndex: currentMaxIndex,
|
||||
currentIndex: currentIndex,
|
||||
})
|
||||
})
|
||||
// ----------------------------------------------
|
||||
|
||||
let params = process.argv.splice(2)
|
||||
let silenced = false
|
||||
if (params.includes('-s')) {
|
||||
silenced = true
|
||||
}
|
||||
params = params.filter((x) => {
|
||||
return !x.startsWith('-')
|
||||
})
|
||||
console.log(params)
|
||||
if (params.length === 0) {
|
||||
console.log('At least 1 parameter required (path to DB)')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const pathA = params[0]
|
||||
const pathB = params[1]
|
||||
|
@ -268,6 +291,7 @@ function difference({ dbA, dbB }) {
|
|||
iterateSubjects(dbA, () => {
|
||||
dbLength++
|
||||
})
|
||||
currentMaxIndex = dbLength
|
||||
|
||||
const getResultDbLength = () => {
|
||||
let resultDbLength = 0
|
||||
|
@ -303,6 +327,7 @@ function difference({ dbA, dbB }) {
|
|||
|
||||
printProgressBar(processedQuestions, dbLength)
|
||||
processedQuestions++
|
||||
currentIndex = processedQuestions
|
||||
|
||||
const res = hasRequiredPercent(searchRes, minpercent)
|
||||
|
||||
|
@ -408,6 +433,7 @@ function hr() {
|
|||
|
||||
function log(text) {
|
||||
utils.AppendToFile(text, globalLog)
|
||||
if (silenced) return
|
||||
if (process.stdout.isTTY) {
|
||||
process.stdout.clearLine()
|
||||
process.stdout.cursorTo(0)
|
||||
|
@ -431,7 +457,7 @@ function writeInSameLine(text, returnToLineStart) {
|
|||
}
|
||||
|
||||
function printProgressBar(current, total) {
|
||||
if (!process.stdout.isTTY) {
|
||||
if (!process.stdout.isTTY || silenced) {
|
||||
return
|
||||
}
|
||||
const width = process.stdout.columns - 30
|
||||
|
@ -462,3 +488,5 @@ function printProgressBar(current, total) {
|
|||
function C(color) {
|
||||
return logger.C(color)
|
||||
}
|
||||
|
||||
process.exit()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue