Skip to content

Commit

Permalink
Render report in tables
Browse files Browse the repository at this point in the history
PR-URL: #161
  • Loading branch information
tshemsedinov committed Jan 29, 2024
1 parent 31a381c commit 616cbc4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions .github/src/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ const loadDir = async (place, options = {}) => {
const match = (expected, answered) => {
const todo = [];
for (const section in expected.sections) {
todo.push(`- ${section}`);
todo.push(`\n| ${section} | actual | ⟶ | required |`);
todo.push(`| --- | --- | --- | --- |`);
const needed = expected.sections[section];
let count = 0;
let have = 0;
Expand All @@ -246,19 +247,21 @@ const match = (expected, answered) => {
const levelIndex = LEVEL_LABELS.indexOf(level || '🤷 unknown');
if (actualIndex < levelIndex) {
upgrade++;
propose.push(` - ${skill}: ${actual}${level}`);
propose.push(`| ${skill} | ${actual} | | ${level} |`);
}
if (actualIndex > levelIndex) above++;
if (actualIndex >= levelIndex && levelIndex !== 0) have++;
}
if (have) todo.push(...propose);
const total = `you have \`${have}\` of \`${count}\` skills`;
const ext = `\`${upgrade}\` to be upgraded, and \`${above}\` above needed`;
todo.push(` - Total: ${total}, ${ext}`);
todo.push(`\nTotal: ${total}, ${ext}`);
}
return todo;
};

const NBSP = '&nbsp;&nbsp;&nbsp;&nbsp;';

const getTotal = (answered) => {
const total = [];
for (const section in answered.sections) {
Expand All @@ -268,7 +271,7 @@ const getTotal = (answered) => {
for (const level of entries) {
if (level) count++;
}
total.push(` - ${section}: \`${count}\` of \`${entries.length}\``);
total.push(`| ${NBSP} ${section} | \`${count}\` | \`${entries.length}\` |`);
if (count > 0) {
overall.count += count;
overall.total += entries.length;
Expand All @@ -291,6 +294,8 @@ const getTotal = (answered) => {
console.log(caption`Match profiles`);
const todos = [];
const totals = ['## Assessment totals\n'];
totals.push(`| Unit | Marked | Of |`);
totals.push(`| ---- | ------ | -- |`);
for (const unit of UNITS) {
console.log(chapter` Unit: ${unit}`);
const expected = roles[unit];
Expand All @@ -300,7 +305,7 @@ const getTotal = (answered) => {
todos.push(`\n## [${unit}](/Skills/${unit}.md)\n`);
todos.push(...todo);
}
totals.push(`- [${unit}](/Skills/${unit}.md)`);
totals.push(`| [${unit}](/Skills/${unit}.md) | | |`);
const total = getTotal(answered);
totals.push(...total);
}
Expand Down

0 comments on commit 616cbc4

Please sign in to comment.