From e94ebf135baa07097e213fe09058c1490fde4035 Mon Sep 17 00:00:00 2001 From: DuXXuD Date: Wed, 29 May 2024 16:44:56 +0200 Subject: [PATCH] diff scripts --- tsscripts/makeDiff.ts | 66 ++++++++++++++++++++++++++++++ tsscripts/package-lock.json | 80 +++++++++++++++++++++++++++++++++++++ tsscripts/package.json | 15 +++++++ 3 files changed, 161 insertions(+) create mode 100644 tsscripts/makeDiff.ts create mode 100644 tsscripts/package-lock.json create mode 100644 tsscripts/package.json diff --git a/tsscripts/makeDiff.ts b/tsscripts/makeDiff.ts new file mode 100644 index 0000000..9954d90 --- /dev/null +++ b/tsscripts/makeDiff.ts @@ -0,0 +1,66 @@ +import * as fs from 'fs'; +import csvParser from 'csv-parser'; + +const ACTUAL_FILE = 'output_actual_view.csv' +const EXPECTED_FILE = 'output_expected_view.csv' +const OUT_TOTALDIFF_FILE = 'totalDiff.json' + +const readCSV = async (filePath: string): Promise => { + return new Promise((resolve, reject) => { + const results: any[] = []; + fs.createReadStream(filePath) + .pipe(csvParser()) + .on('data', (data) => results.push(data)) + .on('end', () => { + resolve(results); + }) + .on('error', (error) => { + reject(error); + }); + }); +}; + +async function makeDiff() { + + const actualData = await readCSV(ACTUAL_FILE); + const expectedData = await readCSV(EXPECTED_FILE); + + if (actualData.length != expectedData.length) throw "DATA LENGTH DIFFERENT" + + let totalDiff : any[] = []; + let indexDiffWhereItShouldnt : any[] = []; + + for(let i=0; i actualData[i].userAccrued) throw "EXPECTED ACCRUED > ACTUAL ACCRUED" + + if (expectedData[i].userIndex != actualData[i].userIndex) { + indexDiffWhereItShouldnt.push({ + actualData: actualData[i], + expectedData: expectedData[i] + }) + + // throw "BOTH INDEX AND ACCRUED DIFFERENT" + } + + // todo: add to accruedDiff + } + } + } + + console.log(JSON.stringify(indexDiffWhereItShouldnt, null, 2)); + + fs.writeFileSync(OUT_TOTALDIFF_FILE, JSON.stringify(totalDiff, null, 2)); +} + +makeDiff(); \ No newline at end of file diff --git a/tsscripts/package-lock.json b/tsscripts/package-lock.json new file mode 100644 index 0000000..5198fa8 --- /dev/null +++ b/tsscripts/package-lock.json @@ -0,0 +1,80 @@ +{ + "name": "tsscripts", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "tsscripts", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@types/node": "^20.12.12", + "csv-parser": "^3.0.0" + } + }, + "node_modules/@types/node": { + "version": "20.12.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz", + "integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/csv-parser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/csv-parser/-/csv-parser-3.0.0.tgz", + "integrity": "sha512-s6OYSXAK3IdKqYO33y09jhypG/bSDHPuyCme/IdEHfWpLf/jKcpitVFyOC6UemgGk8v7Q5u2XE0vvwmanxhGlQ==", + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "csv-parser": "bin/csv-parser" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + } + }, + "dependencies": { + "@types/node": { + "version": "20.12.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz", + "integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==", + "requires": { + "undici-types": "~5.26.4" + } + }, + "csv-parser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/csv-parser/-/csv-parser-3.0.0.tgz", + "integrity": "sha512-s6OYSXAK3IdKqYO33y09jhypG/bSDHPuyCme/IdEHfWpLf/jKcpitVFyOC6UemgGk8v7Q5u2XE0vvwmanxhGlQ==", + "requires": { + "minimist": "^1.2.0" + } + }, + "minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==" + }, + "undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + } + } +} diff --git a/tsscripts/package.json b/tsscripts/package.json new file mode 100644 index 0000000..43e4396 --- /dev/null +++ b/tsscripts/package.json @@ -0,0 +1,15 @@ +{ + "name": "tsscripts", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "@types/node": "^20.12.12", + "csv-parser": "^3.0.0" + } +}