-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract-medium-bugs.ts
More file actions
62 lines (50 loc) · 1.88 KB
/
extract-medium-bugs.ts
File metadata and controls
62 lines (50 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import fs from 'fs';
// Configuration
const INPUT_FILE = 'bugs.json';
const OUTPUT_FILE = 'medium-bugs.json';
const DIFFICULTY_LEVEL = 'medium';
interface Bug {
repo: string;
LLMReviewPassed: boolean;
difficultyLevel?: string;
[key: string]: any;
}
// Get limit from command line argument, default to all bugs if not specified
const limit = process.argv[2] ? parseInt(process.argv[2], 10) : Infinity;
if (isNaN(limit) || limit <= 0) {
console.error('Error: Limit must be a positive number');
process.exit(1);
}
// Read and parse the bugs file
const bugs = JSON.parse(fs.readFileSync(INPUT_FILE, 'utf-8')) as Bug[];
// Filter for bugs that have "medium" difficulty
const mediumBugs = bugs.filter(bug =>
bug.LLMReviewPassed === true &&
bug.difficultyLevel === DIFFICULTY_LEVEL
);
console.log(`Found ${mediumBugs.length} medium bugs out of ${bugs.length} total bugs`);
// Apply limit if needed
const limitedBugs = mediumBugs.slice(0, limit);
console.log(`Using ${limitedBugs.length} medium bugs (limit: ${limit === Infinity ? 'none' : limit})`);
// Group bugs by repository to show distribution
const bugsByRepo = limitedBugs.reduce((acc: { [key: string]: any[] }, bug: any) => {
if (!acc[bug.repo]) {
acc[bug.repo] = [];
}
acc[bug.repo].push(bug);
return acc;
}, {});
// Get list of repos with their bug counts
const repoStats = Object.entries(bugsByRepo)
.map(([repo, bugs]) => ({
repo,
count: bugs.length
}))
.sort((a, b) => b.count - a.count); // Sort by count descending
console.log('\n=== Repositories with Medium Bugs (in output) ===');
repoStats.forEach(({repo, count}) => {
console.log(`${repo}: ${count} medium bugs`);
});
// Write medium bugs to output file
fs.writeFileSync(OUTPUT_FILE, JSON.stringify(limitedBugs, null, 2));
console.log(`\n${limitedBugs.length} medium bugs have been saved to ${OUTPUT_FILE}`);