mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
mergeDuplicateSubjectsAndRmDuplicates.sh
This commit is contained in:
parent
2c031e4d05
commit
c8653805fb
2 changed files with 63 additions and 28 deletions
|
@ -1,13 +1,18 @@
|
|||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const arg = process.argv[2]
|
||||
const files = fs.readdirSync(arg)
|
||||
const resdir = './res'
|
||||
const filesDirPath = process.argv[2]
|
||||
const resdir = process.argv[3]
|
||||
const files = fs.readdirSync(filesDirPath)
|
||||
|
||||
let duplicateSubjects = 0
|
||||
let questionsInDuplicateSubjects = 0
|
||||
|
||||
if (!fs.existsSync(resdir)) {
|
||||
fs.mkdirSync(resdir)
|
||||
}
|
||||
|
||||
function merge(x, y) {
|
||||
return {
|
||||
Name: x.Name,
|
||||
|
@ -18,7 +23,9 @@ function merge(x, y) {
|
|||
const fixQdb = (dbname) => {
|
||||
console.log(dbname)
|
||||
console.log()
|
||||
const file = JSON.parse(fs.readFileSync(path.join(arg + dbname), 'utf8'))
|
||||
const file = JSON.parse(
|
||||
fs.readFileSync(path.join(filesDirPath + dbname), 'utf8')
|
||||
)
|
||||
|
||||
const result = {}
|
||||
|
||||
|
|
28
src/standaloneUtils/mergeDuplicateSubjectsAndRmDuplicates.sh
Executable file
28
src/standaloneUtils/mergeDuplicateSubjectsAndRmDuplicates.sh
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
OUTDIR="/tmp/res/"
|
||||
|
||||
echo "> pwd ${PWD}"
|
||||
|
||||
mkdir -p OUTDIR
|
||||
node ./src/standaloneUtils/duplicateSubjectsInQdbFix.js ./public/questionDbs/ "${OUTDIR}"
|
||||
|
||||
echo -e "\n\n\n"
|
||||
find "${OUTDIR}" -type f | while IFS= read -r qdb; do
|
||||
node \
|
||||
./src/standaloneUtils/rmDuplicates.js \
|
||||
"${qdb}"
|
||||
|
||||
echo -e "\n\n\n"
|
||||
done
|
||||
|
||||
rm -v ${OUTDIR}*.json || exit
|
||||
|
||||
mv -v ./*.res "${OUTDIR}" || exit
|
||||
|
||||
find "${OUTDIR}" -type f | while IFS= read -r qdb; do
|
||||
newName=$(echo "${qdb}" | rev | cut -d '.' -f 2- | rev)
|
||||
mv -v "${qdb}" "${newName}"
|
||||
done
|
||||
|
||||
echo "Done!"
|
Loading…
Add table
Add a link
Reference in a new issue