Skip to content

Commit

Permalink
Status Chart: Avoid emitting consecutive zeros (#1895)
Browse files Browse the repository at this point in the history
* npm update.
* weekly_table.js: 2021-04-30 update.
* Adjust PR Age max and stepSize.
* Update usernames_contributors.txt.
* Avoid emitting consecutive zeros.
* chart.js 3.2.1.
  • Loading branch information
StephanTLavavej authored May 4, 2021
1 parent 25a9215 commit 5e25473
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 55 deletions.
79 changes: 44 additions & 35 deletions gather_stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,13 @@ function write_generated_file(filename, table_str) {
fs.writeFileSync(filename, str);
}

function should_emit_data_point(rows, i, key) {
return rows[i - 1]?.[key] > 0 || rows[i][key] > 0 || rows[i + 1]?.[key] > 0;
}

function write_daily_table(script_start, all_prs, all_issues) {
const rows = [];

const progress_bar = new cliProgress.SingleBar(
{
format: '{bar} {percentage}% | ETA: {eta}s | {value}/{total} days analyzed',
Expand All @@ -339,10 +345,7 @@ function write_daily_table(script_start, all_prs, all_issues) {
);

try {
let str = 'const daily_table = [\n';

const begin = DateTime.fromISO('2019-09-05' + 'T23:00:00');
const begin_cxx23 = DateTime.fromISO('2020-11-10');

progress_bar.start(Math.ceil(script_start.diff(begin).as('days')), 0);

Expand Down Expand Up @@ -390,45 +393,51 @@ function write_daily_table(script_start, all_prs, all_issues) {
}
}

const avg_age = num_pr === 0 ? 0 : combined_pr_age.as('days') / num_pr;
const avg_wait = num_pr === 0 ? 0 : combined_pr_wait.as('days') / num_pr;
const sum_age = combined_pr_age.as('months');
const sum_wait = combined_pr_wait.as('months');

const cells = [
`date: '${when.toISODate()}'`,
`merged: ${Number.parseFloat(num_merged).toFixed(2)}`,
`pr: ${num_pr}`,
`cxx20: ${num_cxx20}`,
];
rows.push({
date: when,
merged: num_merged,
pr: num_pr,
cxx20: num_cxx20,
cxx23: num_cxx23,
lwg: num_lwg,
issue: num_issue,
bug: num_bug,
avg_age: num_pr === 0 ? 0 : combined_pr_age.as('days') / num_pr,
avg_wait: num_pr === 0 ? 0 : combined_pr_wait.as('days') / num_pr,
sum_age: combined_pr_age.as('months'),
sum_wait: combined_pr_wait.as('months'),
});

if (when >= begin_cxx23) {
cells.push(`cxx23: ${num_cxx23}`);
}
progress_bar.increment();
}
} finally {
progress_bar.stop();
}

cells.push(
`lwg: ${num_lwg}`,
`issue: ${num_issue}`,
`bug: ${num_bug}`,
`avg_age: ${Number.parseFloat(avg_age).toFixed(2)}`,
`avg_wait: ${Number.parseFloat(avg_wait).toFixed(2)}`,
`sum_age: ${Number.parseFloat(sum_age).toFixed(2)}`,
`sum_wait: ${Number.parseFloat(sum_wait).toFixed(2)}`,
'},\n'
);
let str = 'const daily_table = [\n';

str += ' { ';
str += cells.join(', ');
for (let i = 0; i < rows.length; ++i) {
const row = rows[i];
str += ' { ';
str += `date: '${row.date.toISODate()}', `;
str += `merged: ${Number.parseFloat(row.merged).toFixed(2)}, `;

progress_bar.increment();
for (const key of ['pr', 'cxx20', 'cxx23', 'lwg', 'issue', 'bug']) {
if (should_emit_data_point(rows, i, key)) {
str += `${key}: ${row[key]}, `;
}
}

str += '];\n';

write_generated_file('./daily_table.js', str);
} finally {
progress_bar.stop();
str += `avg_age: ${Number.parseFloat(row.avg_age).toFixed(2)}, `;
str += `avg_wait: ${Number.parseFloat(row.avg_wait).toFixed(2)}, `;
str += `sum_age: ${Number.parseFloat(row.sum_age).toFixed(2)}, `;
str += `sum_wait: ${Number.parseFloat(row.sum_wait).toFixed(2)}, `;
str += '},\n';
}

str += '];\n';

write_generated_file('./daily_table.js', str);
}

function write_monthly_table(script_start, all_prs) {
Expand Down
12 changes: 6 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
font-weight: bold;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/[email protected].0/dist/chart.min.js"
integrity="sha256-ovnFmAOngtHmlhZzPyGrofexz4Kdik4kEobc8B9r1Yk=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/chart.min.js"
integrity="sha256-uVEHWRIr846/vAdLJeybWxjPNStREzOlqLMXjW/Saeo=" crossorigin="anonymous"></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chartjs-adapter-date-fns.bundle.min.js"
integrity="sha256-xlxh4PaMDyZ72hWQ7f/37oYI0E2PrBbtzi1yhvnG+/E=" crossorigin="anonymous"></script>
Expand Down Expand Up @@ -372,9 +372,9 @@
text: 'Average Age, Average Wait (days)',
},
min: 0,
max: 150,
max: 180,
ticks: {
stepSize: 10,
stepSize: 20,
},
},
rightAxis: {
Expand All @@ -386,9 +386,9 @@
text: 'Combined Age, Combined Wait (PR-months)',
},
min: 0,
max: 150,
max: 180,
ticks: {
stepSize: 10,
stepSize: 20,
},
},
},
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions usernames_contributors.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This is very far from an exhaustive list of contributors, and confers no special status.
# It's simply a list of contributors who have submitted a PR review marked as CHANGES_REQUESTED.

2002Bishwajeet
AdamBucior
AlexGuteniev
fsb4000
Expand Down
1 change: 1 addition & 0 deletions weekly_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,5 @@ const weekly_table = [
{ date: '2021-04-09', vso: 163, libcxx: 579 },
{ date: '2021-04-16', vso: 164, libcxx: 579 },
{ date: '2021-04-23', vso: 173, libcxx: 594 },
{ date: '2021-04-30', vso: 173, libcxx: 594 },
];

0 comments on commit 5e25473

Please sign in to comment.