Skip to content

Commit b134da4

Browse files
[241] Create new getWorkflowTemplateSummary function
1 parent 6198bd2 commit b134da4

2 files changed

Lines changed: 60 additions & 10 deletions

File tree

bin/cli.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,9 @@ program
570570
.command("stats")
571571
.description("Generate an overview with some statistics")
572572
.requiredOption("-s, --since <date>, Specify the date which is going to be used to filter the data from (format: YYYY-MM-DD) (mandatory)")
573-
.option("-w, --workflow [handle]", "Optionally filter test statistics by workflow (workflow handle is optional)")
573+
.option("-w, --workflow [handle], Optionally filter test statistics by workflow (optional)")
574574
.action((options) => {
575-
stats.generateOverview(options.since);
575+
stats.generateOverview(options.since, options.workflow);
576576
});
577577

578578
// Set/Get FIRM ID

lib/cli/stats.js

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@ const fsUtils = require("../utils/fsUtils");
66
const yaml = require("yaml");
77
const { consola } = require("consola");
88

9-
async function generateOverview(sinceDate) {
9+
async function generateOverview(sinceDate, workflow) {
1010
const TODAY = new Date().toJSON().toString().slice(0, 10);
11-
const templateSummary = await getTemplatesSummary();
12-
const yamlSummary = await getYamlSummary(sinceDate);
13-
// Terminal
14-
displayOverview(sinceDate, TODAY, templateSummary, yamlSummary);
15-
// File
16-
const row = createRow(sinceDate, TODAY, templateSummary, yamlSummary);
17-
saveOverviewToFile(row);
11+
if (workflow) {
12+
const templateSummary = await getWorkflowTemplateSummary(workflow);
13+
consola.log("Workflow summary test A")
14+
} else {
15+
const templateSummary = await getTemplatesSummary();
16+
const yamlSummary = await getYamlSummary(sinceDate);
17+
// Terminal
18+
displayOverview(sinceDate, TODAY, templateSummary, yamlSummary);
19+
// File
20+
const row = createRow(sinceDate, TODAY, templateSummary, yamlSummary);
21+
saveOverviewToFile(row);
22+
}
1823
}
1924

2025
// Return an object with the count of activities by file and by type
@@ -255,6 +260,51 @@ async function getTemplatesSummary() {
255260
return summary;
256261
}
257262

263+
async function getWorkflowTemplateSummary(workflowHandle) {
264+
const summary = {
265+
reconciliations: {
266+
total: 0,
267+
externallyManaged: 0,
268+
externallyManagedPerc: 0,
269+
yamlFiles: 0,
270+
yamlFilesPerc: 0,
271+
unitTests: 0,
272+
yamlFilesWithAtLeastTwoTests: 0,
273+
yamlFilesWithAtLeastTwoTestsPerc: 0,
274+
},
275+
exportFiles: {
276+
total: 0,
277+
externallyManaged: 0,
278+
externallyManagedPerc: 0,
279+
},
280+
accountTemplates: {
281+
total: 0,
282+
externallyManaged: 0,
283+
externallyManagedPerc: 0,
284+
yamlFiles: 0,
285+
yamlFilesPerc: 0,
286+
unitTests: 0,
287+
yamlFilesWithAtLeastTwoTests: 0,
288+
yamlFilesWithAtLeastTwoTestsPerc: 0,
289+
},
290+
all: {
291+
total: 0,
292+
externallyManaged: 0,
293+
externallyManagedPerc: 0,
294+
yamlFiles: 0,
295+
yamlFilesPerc: 0,
296+
unitTests: 0,
297+
yamlFilesWithAtLeastTwoTests: 0,
298+
yamlFilesWithAtLeastTwoTestsPerc: 0,
299+
},
300+
};
301+
302+
// Reconciliations
303+
// Assume no empty reconciliations within the workflow.
304+
305+
return summary;
306+
}
307+
258308
async function getYamlSummary(sinceDate) {
259309
const yamlActivity = await yamlFilesActivity(sinceDate);
260310
const summary = { created: 0, updated: 0 };

0 commit comments

Comments
 (0)