chore: remove deps; remove console table
This commit is contained in:
parent
2e0d3d6dba
commit
1b816606b9
2 changed files with 24 additions and 8 deletions
|
@ -4,8 +4,5 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"fetch": "node script-fetch.js",
|
"fetch": "node script-fetch.js",
|
||||||
"eval": "node script-eval.js"
|
"eval": "node script-eval.js"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"uuid": "^11.0.3"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
const uuid = require("uuid");
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
@ -13,6 +12,7 @@ const fs = require('fs');
|
||||||
results.push({
|
results.push({
|
||||||
id: service.id,
|
id: service.id,
|
||||||
hasValidID: hasValidID(service),
|
hasValidID: hasValidID(service),
|
||||||
|
hasValidStatus: hasValidStatus(service),
|
||||||
hasValidName: hasValidName(service),
|
hasValidName: hasValidName(service),
|
||||||
hasValidDescription: hasValidDescription(service),
|
hasValidDescription: hasValidDescription(service),
|
||||||
hasValidURL: hasValidURL(service),
|
hasValidURL: hasValidURL(service),
|
||||||
|
@ -21,11 +21,14 @@ const fs = require('fs');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.table(results);
|
// console.table(results);
|
||||||
|
|
||||||
const totalWithValidID = results.filter(x => x.hasValidID).length;
|
const totalWithValidID = results.filter(x => x.hasValidID).length;
|
||||||
console.log(`# of services with a valid ID: ${totalWithValidID}/${results.length} (${Math.round((totalWithValidID/results.length)*100)}%)`);
|
console.log(`# of services with a valid ID: ${totalWithValidID}/${results.length} (${Math.round((totalWithValidID/results.length)*100)}%)`);
|
||||||
|
|
||||||
|
const totalWithValidStatus = results.filter(x => x.hasValidStatus).length;
|
||||||
|
console.log(`# of services with a valid status: ${totalWithValidStatus}/${results.length} (${Math.round((totalWithValidStatus/results.length)*100)}%)`);
|
||||||
|
|
||||||
const totalWithValidName = results.filter(x => x.hasValidName).length;
|
const totalWithValidName = results.filter(x => x.hasValidName).length;
|
||||||
console.log(`# of services with a valid name: ${totalWithValidName}/${results.length} (${Math.round((totalWithValidName/results.length)*100)}%)`);
|
console.log(`# of services with a valid name: ${totalWithValidName}/${results.length} (${Math.round((totalWithValidName/results.length)*100)}%)`);
|
||||||
|
|
||||||
|
@ -40,11 +43,23 @@ const fs = require('fs');
|
||||||
|
|
||||||
const totalWithValidContact = results.filter(x => x.hasValidContact).length;
|
const totalWithValidContact = results.filter(x => x.hasValidContact).length;
|
||||||
console.log(`# of services with a valid contact: ${totalWithValidContact}/${results.length} (${Math.round((totalWithValidContact/results.length)*100)}%)`);
|
console.log(`# of services with a valid contact: ${totalWithValidContact}/${results.length} (${Math.round((totalWithValidContact/results.length)*100)}%)`);
|
||||||
|
|
||||||
|
console.log("--------------------");
|
||||||
|
|
||||||
|
const totalUsableServices = results.filter(x =>
|
||||||
|
x.hasValidID &&
|
||||||
|
x.hasValidStatus &&
|
||||||
|
x.hasValidName &&
|
||||||
|
x.hasValidDescription &&
|
||||||
|
x.hasValidURL &&
|
||||||
|
x.hasValidOrganisation &&
|
||||||
|
x.hasValidContact).length;
|
||||||
|
|
||||||
|
console.log(`# of valid usable services: ${totalUsableServices}/${results.length} (${Math.round((totalUsableServices/results.length)*100)}%)`);
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
async function loadData(path) {
|
async function loadData(path) {
|
||||||
console.log("Loading from " + path);
|
|
||||||
|
|
||||||
const text = await fs.promises.readFile(path, {
|
const text = await fs.promises.readFile(path, {
|
||||||
encoding: "utf-8"
|
encoding: "utf-8"
|
||||||
});
|
});
|
||||||
|
@ -54,7 +69,9 @@ async function loadData(path) {
|
||||||
|
|
||||||
// Validators
|
// Validators
|
||||||
|
|
||||||
const hasValidID = (s) => uuid.validate(s.id);
|
const hasValidID = (s) => {
|
||||||
|
return /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i.test(s.id.trim());
|
||||||
|
}
|
||||||
|
|
||||||
const hasValidName = (s) => typeof s.name === "string" && s.name.length > 0;
|
const hasValidName = (s) => typeof s.name === "string" && s.name.length > 0;
|
||||||
|
|
||||||
|
@ -72,3 +89,5 @@ const hasValidURL = (s) => {
|
||||||
const hasValidOrganisation = (s) => !!s.organization?.id && !!s.organization?.name;
|
const hasValidOrganisation = (s) => !!s.organization?.id && !!s.organization?.name;
|
||||||
|
|
||||||
const hasValidContact = (s) => !!s.email?.length > 0;
|
const hasValidContact = (s) => !!s.email?.length > 0;
|
||||||
|
|
||||||
|
const hasValidStatus = (s) => s.status === "active";
|
Loading…
Add table
Reference in a new issue