Skip to content

Commit

Permalink
Status Chart: chart.js 3.6.0, improve type info, weekly updates (#2324)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanTLavavej committed Nov 8, 2021
1 parent 00359f4 commit 7827d30
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 51 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -4,7 +4,7 @@ This branch generates the STL's [Status Chart][].

# Getting Started: Repo

1. Install [Node.js][] 16.0.0 or newer.
1. Install [Node.js][] 17.0.1 or newer.
+ You can accept all of the installer's default options.
2. Open a new Command Prompt.
+ You can run `node --version` to verify that Node.js was successfully installed.
Expand Down
4 changes: 2 additions & 2 deletions index.html
Expand Up @@ -26,8 +26,8 @@
font-weight: bold;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.5.1/dist/chart.min.js"
integrity="sha256-bC3LCZCwKeehY6T4fFi9VfOU0gztUa+S4cnkIhVPZ5E=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.6.0/dist/chart.min.js"
integrity="sha256-7lWo7cjrrponRJcS6bc8isfsPDwSKoaYfGIHgSheQkk=" crossorigin="anonymous"></script>
<script
src="https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns@2.0.0/dist/chartjs-adapter-date-fns.bundle.min.js"
integrity="sha256-xlxh4PaMDyZ72hWQ7f/37oYI0E2PrBbtzi1yhvnG+/E=" crossorigin="anonymous"></script>
Expand Down
40 changes: 20 additions & 20 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -29,8 +29,8 @@
"@octokit/graphql": "^4.8.0",
"@types/cli-progress": "^3.9.2",
"@types/luxon": "^2.0.5",
"@types/node": "^16.11.0",
"@types/yargs": "^17.0.4",
"@types/node": "^16.11.6",
"@types/yargs": "^17.0.5",
"cli-progress": "^3.9.1",
"dotenv": "^10.0.0",
"luxon": "^2.0.2",
Expand Down
71 changes: 45 additions & 26 deletions src/gather_stats.ts
Expand Up @@ -58,10 +58,12 @@ type RawLabels = {
nodes: RawLabelNode[];
};

type RawAuthor = {
login: string;
};

type RawReviewNode = {
author: {
login: string;
};
author: RawAuthor | null;
submittedAt: string;
};

Expand All @@ -73,19 +75,31 @@ type RawReviews = {
type RawPRNode = {
id: number;
createdAt: string;
closedAt: string;
mergedAt: string;
closedAt: string | null;
mergedAt: string | null;
labels: RawLabels;
reviews: RawReviews;
};

type RawIssueNode = {
id: number;
createdAt: string;
closedAt: string;
closedAt: string | null;
labels: RawLabels;
};

type RateLimit = {
spent: number;
remaining: number;
limit: number;
};

type RawNodes = {
pr_nodes: RawPRNode[];
issue_nodes: RawIssueNode[];
rate_limit: RateLimit;
};

async function retrieve_nodes_from_network() {
const progress = {
multi_bar: new cliProgress.MultiBar(
Expand All @@ -106,11 +120,8 @@ async function retrieve_nodes_from_network() {
headers: { authorization: `token ${process.env.SECRET_GITHUB_PERSONAL_ACCESS_TOKEN}` },
});

const rate_limit = {
spent: null as null | number,
remaining: null as null | number,
limit: null as null | number,
};
let spent: number;
let limit: number;

{
const query_total_counts = fs.readFileSync('./query_total_counts.graphql', 'utf8');
Expand All @@ -123,15 +134,16 @@ async function retrieve_nodes_from_network() {
},
} = await authorized_graphql(query_total_counts);

rate_limit.spent = rateLimit.cost;
rate_limit.limit = rateLimit.limit;
spent = rateLimit.cost;
limit = rateLimit.limit;

progress.pr_bar = progress.multi_bar.create(total_prs, 0, { name: 'PRs received' });
progress.issue_bar = progress.multi_bar.create(total_issues, 0, { name: 'issues received' });
}

let pr_nodes: RawPRNode[] = [];
let issue_nodes: RawIssueNode[] = [];
let remaining: number;

const variables = {
query: fs.readFileSync('./query_prs_and_issues.graphql', 'utf8'),
Expand All @@ -141,14 +153,14 @@ async function retrieve_nodes_from_network() {
issue_cursor: null as null | string,
};

while (variables.want_prs || variables.want_issues) {
do {
const {
rateLimit,
repository: { pullRequests, issues },
} = await authorized_graphql(variables);

rate_limit.spent += rateLimit.cost;
rate_limit.remaining = rateLimit.remaining;
spent += rateLimit.cost;
remaining = rateLimit.remaining;

if (variables.want_prs) {
variables.want_prs = pullRequests.pageInfo.hasNextPage;
Expand All @@ -163,17 +175,22 @@ async function retrieve_nodes_from_network() {
issue_nodes = issue_nodes.concat(issues.nodes);
progress.issue_bar.update(issue_nodes.length);
}
}
} while (variables.want_prs || variables.want_issues);

return { pr_nodes: pr_nodes, issue_nodes: issue_nodes, rate_limit: rate_limit };
const ret: RawNodes = {
pr_nodes: pr_nodes,
issue_nodes: issue_nodes,
rate_limit: { spent: spent, remaining: remaining, limit: limit },
};
return ret;
} finally {
progress.multi_bar.stop();
}
}

async function retrieve_nodes() {
if (argv['load-file']) {
return JSON.parse(fs.readFileSync(argv['load-file'], 'utf8'));
return JSON.parse(fs.readFileSync(argv['load-file'], 'utf8')) as RawNodes;
}

const graphql_result = await retrieve_nodes_from_network();
Expand Down Expand Up @@ -224,8 +241,8 @@ function read_trimmed_lines(filename: string) {
type DuplicateWarningMessage = (username: string) => string;

function warn_about_duplicates(array: string[], message: DuplicateWarningMessage) {
const uniques = new Set();
const duplicates = new Set();
const uniques = new Set<string>();
const duplicates = new Set<string>();

for (const elem of array) {
if (!uniques.has(elem)) {
Expand Down Expand Up @@ -266,7 +283,7 @@ type CookedPRNode = {
reviews: DateTime[];
};

function transform_pr_nodes(pr_nodes: RawPRNode[]): CookedPRNode[] {
function transform_pr_nodes(pr_nodes: RawPRNode[]) {
warn_if_pagination_needed(
pr_nodes,
(node: RawPRNode) => node.labels,
Expand Down Expand Up @@ -307,13 +324,14 @@ function transform_pr_nodes(pr_nodes: RawPRNode[]): CookedPRNode[] {
})
.map(review_node => DateTime.fromISO(review_node.submittedAt));

return {
const ret: CookedPRNode = {
id: pr_node.id,
opened: DateTime.fromISO(pr_node.createdAt),
closed: DateTime.fromISO(pr_node.closedAt ?? '2100-01-01'),
merged: DateTime.fromISO(pr_node.mergedAt ?? '2100-01-01'),
reviews: maintainer_reviews,
};
return ret;
});
}

Expand All @@ -339,7 +357,7 @@ type CookedIssueNode = {
labeled_bug: boolean;
};

function transform_issue_nodes(issue_nodes: RawIssueNode[]): CookedIssueNode[] {
function transform_issue_nodes(issue_nodes: RawIssueNode[]) {
warn_if_pagination_needed(
issue_nodes,
(node: RawIssueNode) => node.labels,
Expand All @@ -348,7 +366,7 @@ function transform_issue_nodes(issue_nodes: RawIssueNode[]): CookedIssueNode[] {
);
return issue_nodes.map(node => {
const labels = node.labels.nodes.map(label => label.name);
return {
const ret: CookedIssueNode = {
id: node.id,
opened: DateTime.fromISO(node.createdAt),
closed: DateTime.fromISO(node.closedAt ?? '2100-01-01'),
Expand All @@ -357,6 +375,7 @@ function transform_issue_nodes(issue_nodes: RawIssueNode[]): CookedIssueNode[] {
labeled_lwg: labels.includes('LWG') && !labels.includes('vNext') && !labels.includes('blocked'),
labeled_bug: labels.includes('bug'),
};
return ret;
});
}

Expand Down Expand Up @@ -524,7 +543,7 @@ function write_daily_table(script_start: DateTime, all_prs: CookedPRNode[], all_
}

function write_monthly_table(script_start: DateTime, all_prs: CookedPRNode[]) {
const monthly_merges = new Map();
const monthly_merges = new Map<string, number>();

for (const pr of all_prs) {
const year_month = pr.merged.toFormat('yyyy-MM');
Expand Down
3 changes: 3 additions & 0 deletions weekly_table.js
Expand Up @@ -229,4 +229,7 @@ const weekly_table = [
{ date: '2021-10-01', vso: 167, libcxx: 604 },
{ date: '2021-10-08', vso: 168, libcxx: 604 },
{ date: '2021-10-15', vso: 170, libcxx: 595 },
{ date: '2021-10-22', vso: 169, libcxx: 595 },
{ date: '2021-10-29', vso: 170, libcxx: 595 },
{ date: '2021-11-05', vso: 170, libcxx: 595 },
];

0 comments on commit 7827d30

Please sign in to comment.