-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update analysis scripts for new data.
- Loading branch information
Showing
3 changed files
with
123 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import fs from 'node:fs/promises'; | ||
import { quantileSorted } from 'simple-statistics'; | ||
import { RepoSummary } from '../frontend/src/lib/repo-summaries.js'; | ||
|
||
async function main() { | ||
const repoSummaries: { [name: string]: RepoSummary } = {}; | ||
|
||
for (const org of await fs.readdir('../scanner/summaries')) { | ||
if (org.includes('.')) { | ||
continue; | ||
} | ||
for (const repoJson of await fs.readdir(`../scanner/summaries/${org}/`)) { | ||
if (!repoJson.endsWith('.json')) continue; | ||
const repo = repoJson.replace(/\.json$/, ''); | ||
const content = await fs.readFile(`../scanner/summaries/${org}/${repoJson}`, { encoding: 'utf8' }); | ||
repoSummaries[`${org}/${repo}`] = RepoSummary.parse(JSON.parse(content)); | ||
} | ||
} | ||
|
||
const repoLabels: number[] = []; | ||
const repoIssues: number[] = []; | ||
const repoPRs: number[] = []; | ||
const issueLabels: number[] = []; | ||
const issueTimelineItems: number[] = []; | ||
const issueComments: number[] = []; | ||
|
||
for (const repo of Object.values(repoSummaries)) { | ||
if (repo.stats) { | ||
repoLabels.push(repo.stats.numLabels); | ||
repoIssues.push(repo.stats.numIssues); | ||
repoPRs.push(repo.stats.numPRs); | ||
} | ||
for (const issue of repo.issues) { | ||
if (issue.stats) { | ||
issueLabels.push(issue.stats.numLabels); | ||
issueTimelineItems.push(issue.stats.numTimelineItems); | ||
if (issue.stats.numComments) { | ||
issueComments.push(issue.stats.numComments); | ||
} | ||
} | ||
} | ||
} | ||
|
||
function cmpNumber(a: number, b: number) { return a - b; } | ||
repoLabels.sort(cmpNumber); | ||
repoIssues.sort(cmpNumber); | ||
repoPRs.sort(cmpNumber); | ||
issueLabels.sort(cmpNumber); | ||
issueTimelineItems.sort(cmpNumber); | ||
issueComments.sort(cmpNumber); | ||
|
||
console.log('Distribution of the number of matching labels in a repository:'); | ||
console.log(`Median: ${quantileSorted(repoLabels, .5)}`) | ||
console.log(`90%: ${quantileSorted(repoLabels, .9)}`) | ||
console.log(`Max: ${Math.max(...repoLabels)}\n`) | ||
|
||
console.log('Distribution of the number of issues in a repository:'); | ||
console.log(`Median: ${quantileSorted(repoIssues, .5)}`) | ||
console.log(`90%: ${quantileSorted(repoIssues, .9)}`) | ||
console.log(`Max: ${Math.max(...repoIssues)}\n`) | ||
|
||
console.log('Distribution of the number of PRs in a repository:'); | ||
console.log(`Median: ${quantileSorted(repoPRs, .5)}`) | ||
console.log(`90%: ${quantileSorted(repoPRs, .9)}`) | ||
console.log(`95%: ${quantileSorted(repoPRs, .95)}`) | ||
console.log(`99%: ${quantileSorted(repoPRs, .99)}`) | ||
console.log(`Max: ${Math.max(...repoPRs)}\n`) | ||
|
||
console.log('Distribution of the number of labels in an issue/PR:'); | ||
console.log(`Median: ${quantileSorted(issueLabels, .5)}`) | ||
console.log(`90%: ${quantileSorted(issueLabels, .9)}`) | ||
console.log(`Max: ${Math.max(...issueLabels)}\n`) | ||
|
||
console.log('Distribution of the number of timeline items in an issue/PR:'); | ||
console.log(`Median: ${quantileSorted(issueTimelineItems, .5)}`) | ||
console.log(`90%: ${quantileSorted(issueTimelineItems, .9)}`) | ||
console.log(`Max: ${Math.max(...issueTimelineItems)}\n`) | ||
|
||
console.log('Distribution of the number of comments/reviews in an issue/PR:'); | ||
console.log(`Median: ${quantileSorted(issueComments, .5)}`) | ||
console.log(`90%: ${quantileSorted(issueComments, .9)}`) | ||
console.log(`95%: ${quantileSorted(issueComments, .95)}`) | ||
console.log(`99%: ${quantileSorted(issueComments, .99)}`) | ||
console.log(`Max: ${Math.max(...issueComments)}\n`) | ||
} | ||
|
||
await main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,37 @@ | ||
import { Temporal, toTemporalInstant } from '@js-temporal/polyfill'; | ||
import { z } from 'zod'; | ||
|
||
export const SloType = z.enum(["triage", "urgent", "important", "none"]); | ||
export type SloType = z.infer<typeof SloType>; | ||
|
||
const durationInMs = z.number().transform(val => Temporal.Duration.from({ milliseconds: Math.round(val) })); | ||
|
||
export const IssueSummary = z.object({ | ||
url: z.string().url(), | ||
title: z.string(), | ||
created_at: z.coerce.date().transform(val => toTemporalInstant.call(val)), | ||
closed_at: z.coerce.date().transform(val => toTemporalInstant.call(val)).optional(), | ||
createdAt: z.coerce.date().transform(val => toTemporalInstant.call(val)), | ||
pull_request: z.object({ draft: z.boolean().default(false) }).optional(), | ||
milestone: z.string().optional(), | ||
labels: z.array(z.string()), | ||
ageAtCloseMs: z.number().optional(), | ||
firstCommentLatencyMs: z.number().optional(), | ||
sloTimeUsedMs: durationInMs, | ||
whichSlo: SloType, | ||
stats: z.object({ | ||
numTimelineItems: z.number(), | ||
numComments: z.number().optional(), | ||
numLabels: z.number(), | ||
}).optional(), | ||
}) | ||
export type IssueSummary = z.infer<typeof IssueSummary>; | ||
|
||
const durationInMs = z.number().transform(val => Temporal.Duration.from({ milliseconds: Math.round(val) })); | ||
|
||
export const AgeStats = z.object({ | ||
count: z.number(), | ||
mean: durationInMs, | ||
10: durationInMs, | ||
25: durationInMs, | ||
50: durationInMs, | ||
75: durationInMs, | ||
90: durationInMs, | ||
}); | ||
export type AgeStats = z.infer<typeof AgeStats>; | ||
|
||
export const RepoSummary = z.object({ | ||
cachedAt: z.number().transform(val => Temporal.Instant.fromEpochMilliseconds(val)), | ||
org: z.string(), | ||
repo: z.string(), | ||
issues: IssueSummary.array(), | ||
labelsPresent: z.boolean(), | ||
ageAtCloseMs: AgeStats.optional(), | ||
openAgeMs: AgeStats.optional(), | ||
firstCommentLatencyMs: AgeStats.optional(), | ||
openFirstCommentLatencyMs: AgeStats.optional(), | ||
closedFirstCommentLatencyMs: AgeStats.optional(), | ||
stats: z.object({ | ||
numLabels: z.number(), | ||
numIssues: z.number(), | ||
numPRs: z.number(), | ||
}).optional(), | ||
}); | ||
export type RepoSummary = z.infer<typeof RepoSummary>; |