mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Merger print fixing
This commit is contained in:
parent
45e04547cc
commit
122873ce4e
1 changed files with 56 additions and 5 deletions
61
merger.js
61
merger.js
|
@ -136,12 +136,14 @@ var actions = require('./actions.js');
|
||||||
Main();
|
Main();
|
||||||
|
|
||||||
function Main() {
|
function Main() {
|
||||||
|
console.clear();
|
||||||
const params = GetParams();
|
const params = GetParams();
|
||||||
console.log(params);
|
console.log(params);
|
||||||
var dbs = [];
|
var dbs = [];
|
||||||
|
|
||||||
|
|
||||||
for (var i = 0; i < params.length; i++) {
|
for (var i = 0; i < params.length; i++) {
|
||||||
|
PrintLN();
|
||||||
console.log(params[i] + ": ");
|
console.log(params[i] + ": ");
|
||||||
try {
|
try {
|
||||||
dbs.push(ParseJSONData(utils.ReadFile(params[i])));
|
dbs.push(ParseJSONData(utils.ReadFile(params[i])));
|
||||||
|
@ -151,10 +153,15 @@ function Main() {
|
||||||
console.log("Trying with old format...");
|
console.log("Trying with old format...");
|
||||||
dbs.push(ReadData(utils.ReadFile(params[i])).result);
|
dbs.push(ReadData(utils.ReadFile(params[i])).result);
|
||||||
}
|
}
|
||||||
console.log("---------------------------------");
|
|
||||||
}
|
}
|
||||||
|
PrintLN();
|
||||||
|
|
||||||
|
dbs.forEach((item) => {
|
||||||
|
PrintDB(item);
|
||||||
|
});
|
||||||
|
|
||||||
console.log("Parsed data count: " + dbs.length);
|
console.log("Parsed data count: " + dbs.length);
|
||||||
console.log("---------------------------------");
|
PrintLN();
|
||||||
|
|
||||||
console.log("Merging databases...");
|
console.log("Merging databases...");
|
||||||
var db = MergeDatabases(dbs);
|
var db = MergeDatabases(dbs);
|
||||||
|
@ -162,14 +169,58 @@ function Main() {
|
||||||
console.log("Removing duplicates...");
|
console.log("Removing duplicates...");
|
||||||
var r = RemoveDuplicates(db);
|
var r = RemoveDuplicates(db);
|
||||||
|
|
||||||
for (var i = 0; i < r.length; i++) {
|
console.log("RESULT:");
|
||||||
console.log(i + ": " + r.Subjects[i].Name + ": " + r.Subjects[i].length + " db");
|
PrintDB(r);
|
||||||
}
|
|
||||||
|
|
||||||
utils.WriteFile(JSON.stringify(r), "newData");
|
utils.WriteFile(JSON.stringify(r), "newData");
|
||||||
console.log("File written!");
|
console.log("File written!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function PrintLN() {
|
||||||
|
console.log("------------------------------------------------------");
|
||||||
|
}
|
||||||
|
|
||||||
|
function PrintDB(r) {
|
||||||
|
console.log("Data subject count: " + r.length);
|
||||||
|
var maxLength = 0;
|
||||||
|
for (var i = 0; i < r.length; i++) {
|
||||||
|
if (maxLength < r.Subjects[i].Name.length)
|
||||||
|
maxLength = r.Subjects[i].Name.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("MAXL" + maxLength);
|
||||||
|
|
||||||
|
for (var i = 0; i < r.length; i++) {
|
||||||
|
let line = i;
|
||||||
|
if (line < 10)
|
||||||
|
line += ' ';
|
||||||
|
|
||||||
|
line += ": ";
|
||||||
|
var currLength = line.length + maxLength + 4;
|
||||||
|
line += r.Subjects[i].Name;
|
||||||
|
|
||||||
|
while (line.length < currLength) {
|
||||||
|
if (i % 4 == 0)
|
||||||
|
line += ".";
|
||||||
|
else
|
||||||
|
line += " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r.Subjects[i].length < 10)
|
||||||
|
line += " ";
|
||||||
|
if (r.Subjects[i].length < 100)
|
||||||
|
line += " ";
|
||||||
|
|
||||||
|
line += r.Subjects[i].length;
|
||||||
|
|
||||||
|
line += " db";
|
||||||
|
|
||||||
|
console.log(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintLN();
|
||||||
|
}
|
||||||
|
|
||||||
function GetParams() {
|
function GetParams() {
|
||||||
return process.argv.splice(2);
|
return process.argv.splice(2);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue