-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
455 lines (452 loc) · 18 KB
/
index.html
File metadata and controls
455 lines (452 loc) · 18 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Commitfest Patch Ranker (Experimental) – 03/2025</title>
<!-- Google Font for a modern look -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
<!-- External libraries -->
<script src="https://code.jquery.com/jquery-3.7.1.slim.js"
integrity="sha256-UgvvN8vBkgO0luPSUl2s8TIlOSYRoGFAX4jlCIm9Adc=" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/simple-datatables@latest/dist/style.css" rel="stylesheet" type="text/css">
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@latest" type="text/javascript"></script>
<script defer src="https://cdn.vercel-insights.com/v1/script.js"></script>
<style>
/* Global Reset & Typography */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Inter', sans-serif;
background: #f7f9fc;
color: #333;
line-height: 1.6;
padding: 20px;
}
/* Main container styling */
#main {
max-width: 1200px;
margin: 0 auto;
background: #fff;
padding: 30px;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
header {
text-align: center;
margin-bottom: 20px;
}
header h1 {
font-size: 2rem;
margin-bottom: 10px;
color: #2c3e50;
}
header p {
font-size: 1rem;
color: #555;
}
header p a {
color: #3498db;
text-decoration: none;
}
header p a:hover {
text-decoration: underline;
}
/* Controls styling */
#controls {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
margin: 20px 0;
border-bottom: 1px solid #e0e0e0;
padding-bottom: 10px;
}
#controls select {
padding: 8px 12px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1rem;
margin-bottom: 10px;
}
#controls a,
#controls strong {
margin: 0 8px;
font-size: 1rem;
cursor: pointer;
color: #333;
}
#controls a:hover {
color: #3498db;
}
/* Content and Table sections */
#content {
margin: 20px 0;
}
#table {
overflow-x: auto;
}
/* Footer styling */
footer {
text-align: center;
font-size: 0.9rem;
color: #888;
margin-top: 20px;
}
</style>
<script>
// Vercel Insights snippet (for analytics)
window.va = function () {
(window.vaq = window.vaq || []).push(arguments);
};
window.va('beforeSend', (event) => {
if (event.url.includes('/private')) {
return null;
}
return event;
});
</script>
</head>
<body>
<div id="main">
<header>
<h1>03/2025 Commitfest Patch Ranker (Experimental)</h1>
<p>
How it works: An LLM reads through mailing list threads to determine patch statuses and
cross-references file changes against your history. It ranks patches based on whether you’ve
committed in the past or been credited as an author/reviewer/etc in the commit message.
<br>
<a href="https://github.com/polkerty/patchwork" target="_blank">Repository</a> |
<a href="mailto:jacob.brazeal@gmail.com">Contact</a> |
<span id="last-updated"></span>
</p>
</header>
<!-- Controls: contributor selector and filter options -->
<section id="controls">
<div id="contributor-select"></div>
<div id="filter-options"></div>
</section>
<!-- Main content area -->
<section id="content">
<h2>Please select your name to see your personalized patch review recommendations</h2>
</section>
<!-- Table container for patch data -->
<section id="table">
<div id="table_inner"></div>
</section>
<footer>
</footer>
</div>
<script>
// DATA and STATE objects store the fetched data and computed lookups.
const DATA = {};
const STATE = {};
const BEGINNER_THRESHOLD = 7;
const FILTER_ENUM = {
"RECOMMENDED": "Recommended patches for you to check",
"ALL": "All patches",
"MY_REVIEWS": "My mailing threads",
"MY_PATCHES": "Patches I wrote",
"BEGINNERS": "Patches for a beginner to review"
};
// Utility function to display a contributor's name.
function displayName(name) {
return STATE.byContributor[name]?.display_name || name;
}
// Handler for when a contributor is selected.
function setContributor(event) {
const contributor = event.target.value || undefined;
STATE.contributor = contributor;
renderContent();
}
// Render the contributor dropdown and filter options.
function renderControls() {
let contributorHTML = `
<select onchange="setContributor(event)">
<option value="" ${!STATE.contributor ? 'selected' : ''}>Select your name...</option>
${STATE.contributors.map(c => `<option value="${c}" ${STATE.contributor === c ? 'selected' : ''}>${displayName(c)}</option>`).join('')}
</select>
`;
let filterHTML = `<strong style="margin-right: 10px;">Filter:</strong>`;
for (const [key, label] of Object.entries(FILTER_ENUM)) {
if (STATE.filter === label) {
filterHTML += `<strong>${label}</strong>`;
} else {
filterHTML += `<a onclick='setFilter("${label}")'>${label}</a>`;
}
filterHTML += `<span style="margin: 0 5px;">|</span>`;
}
$('#contributor-select').html(contributorHTML);
$('#filter-options').html(filterHTML);
}
// Set a new filter and re-render.
function setFilter(filter) {
STATE.filter = filter;
render();
}
// Prepare patch data based on the current contributor and filter.
function getPatchData() {
let patches = DATA.patches.map(x => ({ ...x }));
const rankings = Object.fromEntries(
DATA.rankings.filter(x => x.reviewer === STATE.contributor)
.map(x => [x.patch, { ...x }])
);
for (const patch of patches) {
patch.rankData = rankings[patch.patch_id];
patch.fileSimilarityRank = rankings[patch.patch_id]?.rank || patches.length;
patch.commitfest = { ...STATE.patchById[patch.patch_id] };
patch.threads = STATE.threadsOfPatch[patch.patch_id].map(thread => STATE.byThread[thread]);
patch.beginnerScore = Math.min(...patch.threads.map(thread => thread.beginners.score));
patch.constructedRank = (function() {
let best = patch.fileSimilarityRank;
for (const thread of patch.threads) {
if (thread.predictedCommitters.a === STATE.contributor) {
let score = -3000 - (100 * thread.predictedCommitters.score_a);
if (score < best) {
best = score;
patch.selfCommitReasons = thread.predictedCommitters.terms_a;
}
} else if (thread.predictedCommitters.b === STATE.contributor) {
let score = -2000 - (100 * thread.predictedCommitters.score_b);
if (score < best) {
best = score;
patch.selfCommitReasons = thread.predictedCommitters.terms_b;
}
} else if (thread.predictedCommitters.c === STATE.contributor) {
let score = -1000 - (100 * thread.predictedCommitters.score_c);
if (score < best) {
best = score;
patch.selfCommitReasons = thread.predictedCommitters.terms_c;
}
}
}
return best;
})();
patch.newReviewer = patch.threads.some(t => t.would_benefit_from_new_reviewer === 'YES') ? 'Yes' : 'No';
// Duplicate IDs to work around table library quirks.
patch.patch_id_2 = patch.patch_id;
patch.patch_id_3 = patch.patch_id;
}
patches.sort((a, b) => a.constructedRank - b.constructedRank);
patches.forEach((patch, index) => patch.rank = index + 1);
switch (STATE.filter) {
case FILTER_ENUM.ALL:
break;
case FILTER_ENUM.RECOMMENDED:
patches = patches.filter(patch => patch.newReviewer === 'Yes');
break;
case FILTER_ENUM.MY_REVIEWS:
patches = patches.filter(patch => patch.threads.some(t => t.stats.reviewer_list.some(r => r.toLowerCase() === STATE.contributor.toLowerCase())));
break;
case FILTER_ENUM.MY_PATCHES:
patches = patches.filter(patch => patch.threads.some(t => t.stats.author.toLowerCase() === STATE.contributor.toLowerCase()));
break;
case FILTER_ENUM.BEGINNERS:
patches = patches.filter(patch => patch.beginnerScore >= BEGINNER_THRESHOLD);
break;
default:
break;
}
return patches;
}
// Renders the patch data table using the simple-datatables library.
function renderContent() {
if (!STATE.contributor) {
$("#content").html('<h2>Please select your name to see your personalized patch review recommendations</h2>');
$("#table").html("");
return;
}
const patchData = getPatchData();
STATE.table = patchData;
$('#table').html("<div id='table_inner'></div>");
new window.simpleDatatables.DataTable('#table_inner', {
searchable: true,
fixedHeight: true,
columns: [
{ select: 0 },
{
select: 1,
render: renderNameLink,
searchMethod: (terms, cell) => {
const entry = STATE.patchById[cell.data[0].data];
return terms.every(term => entry.name.toLowerCase().includes(term.toLowerCase()));
}
},
{ select: 3, ...(STATE.filter === FILTER_ENUM.BEGINNERS ? {} : { sort: "asc" }) },
{ select: 4, render: renderBeginnerScore },
{ select: 5, render: renderThreads }
],
data: {
headings: [
{ text: "ID", data: "patch_id" },
{ text: "Name", data: 'patch_id_2' },
{ text: "[LLM] Needs additional reviewer?", data: "newReviewer" },
{ text: "Rank for you", data: "rank" },
{ text: "Suitable for a novice reviewer?", data: "beginnerScore" },
{ text: "Threads", data: "patch_id_3" },
],
data: patchData
}
});
}
// Render a clickable link for the patch name.
const renderNameLink = function (data, cell) {
const entry = STATE.patchById[data[0].data];
cell.childNodes = [
{ nodeName: "span", attributes: { style: "display:none;" }, childNodes: [{ nodeName: "#text", data: entry.name }] },
{ nodeName: "a", attributes: { href: `https://commitfest.postgresql.org/patch/${entry.patch_id}/`, target: "_blank" }, childNodes: [{ nodeName: "#text", data: entry.name }] }
];
}
// Render a yes/no value for beginner score.
const renderBeginnerScore = function (data, cell) {
const score = Number(data[0].data);
const value = score >= BEGINNER_THRESHOLD ? 'Yes' : 'No';
cell.childNodes = [{ nodeName: "#text", data: value }];
}
// Render detailed thread information.
const renderThreads = function (data, cell) {
const entry = STATE.patchById[data[0].data];
const threads = STATE.threadsOfPatch[entry.id].map(thread => STATE.byThread[thread]);
const myCommitReasons = {};
threads.forEach(thread => {
if (thread.predictedCommitters.a === STATE.contributor) {
myCommitReasons[thread.id] = thread.predictedCommitters.terms_a;
} else if (thread.predictedCommitters.b === STATE.contributor) {
myCommitReasons[thread.id] = thread.predictedCommitters.terms_b;
} else if (thread.predictedCommitters.c === STATE.contributor) {
myCommitReasons[thread.id] = thread.predictedCommitters.terms_c;
}
});
cell.childNodes = [{
nodeName: "div",
childNodes: threads.flatMap(thread => ([
{ nodeName: "a", attributes: { href: `https://postgr.es/m/${thread.id}`, target: "_blank" }, childNodes: [{ nodeName: "#text", data: "Link to thread" }] },
{ nodeName: "br" },
{ nodeName: "strong", attributes: { style: "margin-right: 10px;" }, childNodes: [{ nodeName: "#text", data: "[LLM] Thread status" }] },
{ nodeName: "span", childNodes: [{ nodeName: "#text", data: thread.status }] },
{ nodeName: "br" },
{ nodeName: "strong", attributes: { style: "margin-right: 10px;" }, childNodes: [{ nodeName: "#text", data: "Suggested Committers:" }] },
{ nodeName: "span", childNodes: [{ nodeName: "#text", data: displayName(thread.predictedCommitters.a) + " / " + displayName(thread.predictedCommitters.b) + " / " + displayName(thread.predictedCommitters.c) }] },
{ nodeName: "br" },
...(myCommitReasons[thread.id] ? [
{ nodeName: "strong", attributes: { style: "margin-right: 10px;" }, childNodes: [{ nodeName: "#text", data: "Topics in thread associated with me: " }] },
{ nodeName: "span", childNodes: [{ nodeName: "#text", data: myCommitReasons[thread.id] }] },
{ nodeName: "br" }
] : []),
{ nodeName: "strong", attributes: { style: "margin-right: 10px;" }, childNodes: [{ nodeName: "#text", data: "Author: " }] },
{ nodeName: "span", childNodes: [{ nodeName: "#text", data: thread.stats.author }] },
{ nodeName: "br" },
{ nodeName: "strong", attributes: { style: "margin-right: 10px;" }, childNodes: [{ nodeName: "#text", data: "Also in thread: " }] },
{ nodeName: "span", childNodes: [{ nodeName: "#text", data: thread.stats.reviewer_list.map(displayName).join(', ') }] },
{ nodeName: "br" },
{ nodeName: "strong", attributes: { style: "margin-right: 10px;" }, childNodes: [{ nodeName: "#text", data: "[LLM] Activity" }] },
{ nodeName: "span", childNodes: [{ nodeName: "#text", data: thread.activity }] },
{ nodeName: "br" },
{ nodeName: "strong", childNodes: [{ nodeName: "#text", data: "Last message:" }] },
{ nodeName: "span", childNodes: [{ nodeName: "#text", data: thread.stats.last_activity }] },
{ nodeName: "br" },
{ nodeName: "strong", childNodes: [{ nodeName: "#text", data: "[LLM] Summary: " }] },
{ nodeName: "span", childNodes: [{ nodeName: "#text", data: thread.summary }] },
{ nodeName: "br" },
{ nodeName: "strong", childNodes: [{ nodeName: "#text", data: "Main Issue: " }] },
{ nodeName: "span", childNodes: [{ nodeName: "#text", data: thread.problem }] },
...(thread.beginners.score >= BEGINNER_THRESHOLD ? [
{ nodeName: "br" },
{ nodeName: "strong", childNodes: [{ nodeName: "#text", data: "For beginners: " }] },
{ nodeName: "span", childNodes: [{ nodeName: "#text", data: thread.beginners.explanation }] }
] : []),
{ nodeName: "br" },
{ nodeName: "img", attributes: { src: "data/svg/" + thread.id + ".svg", height: "200" }, childNodes: [] },
{ nodeName: "br" }
]))
}];
}
// Update the "last updated" text.
function renderLastUpdated() {
$('#last-updated').html("<strong>Last updated</strong>: " + STATE.lastUpdated.toLocaleString() + "; any entries after that time are not yet shown.");
}
// Main render function.
function render() {
renderControls();
renderContent();
renderLastUpdated();
}
// Build lookup tables for efficient data access.
function constructLookups() {
const patchById = {};
DATA.patches.forEach(patch => {
patchById[patch.patch_id] = patch;
});
const threadsOfPatch = {};
DATA.patchMessage.forEach(({ patch, message }) => {
if (!threadsOfPatch[patch]) {
threadsOfPatch[patch] = [];
}
threadsOfPatch[patch].push(message);
});
const byThread = {};
DATA.threadSummaries.forEach(thread => {
byThread[thread.id] = thread;
});
DATA.threadStats.forEach(thread => {
if (byThread[thread.message_id]) {
byThread[thread.message_id].stats = thread;
} else {
console.log("No summary for thread: " + thread.message_id);
}
});
DATA.predictedCommitters.forEach(thread => {
if (byThread[thread.thread]) {
byThread[thread.thread].predictedCommitters = thread;
} else {
console.log("No summary for thread: " + thread.thread);
}
});
DATA.beginners.forEach(thread => {
if (byThread[thread.thread]) {
byThread[thread.thread].beginners = thread;
}
});
const byContributor = {};
DATA.contributors.forEach(contributor => {
byContributor[contributor.name] = contributor;
});
return { patchById, threadsOfPatch, byThread, byContributor };
}
// Initial data load.
(async () => {
const dataBaseURL = 'data/';
const [
threadSummaries,
rankings,
patches,
threadStats,
patchMessage,
predictedCommitters,
contributors,
beginners,
] = await Promise.all([
'thread_summaries.json',
'contrib_tf_idf.json',
'patches.json',
'thread_stats.json',
'patch_message.json',
'predicted_committers.json',
'contributors.json',
'beginners.json',
].map(url => fetch(dataBaseURL + url + "?nocache=" + Math.random().toString().slice(2))
.then(x => x.json())));
Object.assign(DATA, { threadSummaries, rankings, patches, threadStats, patchMessage, predictedCommitters, contributors, beginners });
Object.assign(STATE, constructLookups());
STATE.contributors = [...new Set(DATA.rankings.map(x => x.reviewer))];
STATE.lastUpdated = new Date(Math.max(...DATA.threadStats.map(thread => new Date(thread.last_activity))));
STATE.filter = FILTER_ENUM.RECOMMENDED;
render();
STATE.contributor = '';
})();
</script>
</body>
</html>