testilo 7.0.6 → 7.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/call.js +8 -30
- package/digest.js +1 -1
- package/multiScore.js +11 -8
- package/package.json +1 -1
- package/score.js +2 -2
package/call.js
CHANGED
|
@@ -117,34 +117,12 @@ const callScore = async (scoreProcID, reportIDStart = '') => {
|
|
|
117
117
|
};
|
|
118
118
|
// Fulfills a multiple-report scoring request.
|
|
119
119
|
const callMultiScore = async scoreProcID => {
|
|
120
|
-
//
|
|
121
|
-
|
|
122
|
-
const rawReportNames = rawFileNames.filter(fileName => fileName.endsWith('.json'));
|
|
123
|
-
// If any exist:
|
|
124
|
-
if (rawReportNames.length) {
|
|
125
|
-
// For each of them:
|
|
126
|
-
const {scorer} = require(`${scoreProcDir}/${scoreProcID}.js`);
|
|
127
|
-
for (const rawReportName of rawReportNames) {
|
|
128
|
-
// Score it.
|
|
129
|
-
const rawReportJSON = await fs.readFile(`${rawDir}/${rawReportName}.json`);
|
|
130
|
-
const rawReport = JSON.parse(rawReportJSON);
|
|
131
|
-
const scoredReport = score(scorer, rawReport);
|
|
132
|
-
// Save it, scored.
|
|
133
|
-
await fs.writeFile(
|
|
134
|
-
`${scoredDir}/${scoredReport.id}.json`, JSON.stringify(scoredReport, null, 2)
|
|
135
|
-
);
|
|
136
|
-
console.log(`Report ${rawReport.id} scored and saved in ${scoredDir}`);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
// Otherwise, i.e. if no raw report exists:
|
|
140
|
-
else {
|
|
141
|
-
// Report this.
|
|
142
|
-
console.log('ERROR: No raw report found');
|
|
143
|
-
}
|
|
120
|
+
// Score all raw reports.
|
|
121
|
+
await multiScore(scoreProcID);
|
|
144
122
|
};
|
|
145
123
|
// Prepares to fulfill a digesting request.
|
|
146
124
|
const digestPrep = async digestProcID => {
|
|
147
|
-
const {digest} = require('
|
|
125
|
+
const {digest} = require('./digest');
|
|
148
126
|
const {makeQuery} = require(`${digestProcDir}/${digestProcID}/index`);
|
|
149
127
|
const digestTemplate = await fs.readFile(`${digestProcDir}/${digestProcID}/index.html`, 'utf8');
|
|
150
128
|
// Identify the scored reports.
|
|
@@ -162,12 +140,12 @@ const digestPrep = async digestProcID => {
|
|
|
162
140
|
// Digests and saves a report.
|
|
163
141
|
const digestReport = async (scoredReportName, prepData) => {
|
|
164
142
|
// Digest the specified report.
|
|
165
|
-
const scoredReportJSON = await fs.readFile(`${scoredDir}/${scoredReportName}
|
|
143
|
+
const scoredReportJSON = await fs.readFile(`${scoredDir}/${scoredReportName}`, 'utf8');
|
|
166
144
|
const scoredReport = JSON.parse(scoredReportJSON);
|
|
167
145
|
const digestedReport = digest(prepData.digestTemplate, prepData.makeQuery, scoredReport);
|
|
168
146
|
// Save it, digested.
|
|
169
|
-
await fs.writeFile(`${digestedDir}/${
|
|
170
|
-
console.log(`
|
|
147
|
+
await fs.writeFile(`${digestedDir}/${scoredReport.job.id}.html`, digestedReport);
|
|
148
|
+
console.log(`Digested report ${scoredReport.job.id} saved in ${digestedDir}`);
|
|
171
149
|
};
|
|
172
150
|
// Fulfills a digesting request.
|
|
173
151
|
const callDigest = async (digestProcID, reportIDStart = '') => {
|
|
@@ -218,14 +196,14 @@ const callMultiDigest = async digestProcID => {
|
|
|
218
196
|
console.log('ERROR: No raw report found');
|
|
219
197
|
}
|
|
220
198
|
console.log(
|
|
221
|
-
`Digesting completed. Digest proc: ${digestProcID}. Report count: ${prepData.scoredReportNames.length}. Directory: ${digestedDir}
|
|
199
|
+
`Digesting completed. Digest proc: ${digestProcID}. Report count: ${prepData.scoredReportNames.length}. Directory: ${digestedDir}.`
|
|
222
200
|
);
|
|
223
201
|
};
|
|
224
202
|
// Fulfills a comparison request.
|
|
225
203
|
const callCompare = async (compareProcID, comparisonNameBase) => {
|
|
226
204
|
await compare(compareProcID, comparisonNameBase);
|
|
227
205
|
console.log(
|
|
228
|
-
`Comparison completed. Comparison proc: ${compareProcID}. Directory: ${comparisonDir}
|
|
206
|
+
`Comparison completed. Comparison proc: ${compareProcID}. Directory: ${comparisonDir}.`
|
|
229
207
|
);
|
|
230
208
|
};
|
|
231
209
|
|
package/digest.js
CHANGED
|
@@ -20,6 +20,6 @@ exports.digest = (digestTemplate, digestProc, scoredReport) => {
|
|
|
20
20
|
// Use it to replace the placeholders in the template.
|
|
21
21
|
const digest = replaceHolders(digestTemplate, query);
|
|
22
22
|
// Return the digest.
|
|
23
|
-
console.log(`Report ${scoredReport.id} digested`);
|
|
23
|
+
console.log(`Report ${scoredReport.job.id} digested`);
|
|
24
24
|
return digest;
|
|
25
25
|
};
|
package/multiScore.js
CHANGED
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
require('dotenv').config();
|
|
15
15
|
// Module to read and write files.
|
|
16
16
|
const fs = require('fs/promises');
|
|
17
|
+
// Module to score reports.
|
|
18
|
+
const {score} = require('./score');
|
|
17
19
|
|
|
18
20
|
// ########## CONSTANTS
|
|
19
21
|
|
|
@@ -25,21 +27,22 @@ const scoreProcDir = process.env.SCOREPROCDIR || `${__dirname}/procs/score`;
|
|
|
25
27
|
|
|
26
28
|
// Score the specified reports and return their count.
|
|
27
29
|
exports.multiScore = async scoreProcID => {
|
|
30
|
+
// Get the score proc.
|
|
31
|
+
const {scorer} = require(`${scoreProcDir}/${scoreProcID}`);
|
|
28
32
|
// Identify the reports to be scored.
|
|
29
33
|
let reportFileNames = await fs.readdir(reportDirRaw);
|
|
30
34
|
reportFileNames = reportFileNames.filter(fileName => fileName.endsWith('.json'));
|
|
31
35
|
// For each of them:
|
|
32
|
-
const {scorer} = require(`${scoreProcDir}/${scoreProcID}`);
|
|
33
36
|
for (const fileName of reportFileNames) {
|
|
34
37
|
// Score it.
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
await scorer
|
|
38
|
-
report.scoreProcID = scoreProcID;
|
|
38
|
+
const rawReportJSON = await fs.readFile(`${reportDirRaw}/${fileName}`, 'utf8');
|
|
39
|
+
const rawReport = JSON.parse(rawReportJSON);
|
|
40
|
+
const scoredReport = await score(scorer, rawReport);
|
|
39
41
|
// Write it to a file.
|
|
40
|
-
const scoredReportJSON = JSON.stringify(
|
|
42
|
+
const scoredReportJSON = JSON.stringify(scoredReport, null, 2);
|
|
41
43
|
await fs.writeFile(`${reportDirScored}/${fileName}`, `${scoredReportJSON}\n`);
|
|
42
|
-
console.log(`Report ${fileName.slice(0, -5)} scored and saved`);
|
|
43
44
|
};
|
|
44
|
-
|
|
45
|
+
console.log(
|
|
46
|
+
`Scored reports saved in ${reportDirScored}. Report count: ${reportFileNames.length}.`
|
|
47
|
+
);
|
|
45
48
|
};
|
package/package.json
CHANGED
package/score.js
CHANGED
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
// ########## FUNCTIONS
|
|
10
10
|
|
|
11
11
|
// Score the specified raw report and return it, scored.
|
|
12
|
-
exports.score = async (
|
|
12
|
+
exports.score = async (scorer, rawReport) => {
|
|
13
13
|
// Initialize a scored report.
|
|
14
14
|
const scoredReport = JSON.parse(JSON.stringify(rawReport));
|
|
15
15
|
// Score it.
|
|
16
|
-
await
|
|
16
|
+
await scorer(scoredReport);
|
|
17
17
|
console.log(`Report ${rawReport.job.id} scored`);
|
|
18
18
|
return scoredReport;
|
|
19
19
|
};
|