diff --git a/changelog.d/added-abandoned-leaderboards.md b/changelog.d/added-abandoned-leaderboards.md new file mode 100644 index 0000000000..c7eb5e95a2 --- /dev/null +++ b/changelog.d/added-abandoned-leaderboards.md @@ -0,0 +1 @@ +- Show abandoned PR counts in the dashboard and contribute landing leaderboards without changing contributor rankings ([#15796](https://github.com/hivecommons/hive/issues/15796)). diff --git a/src/pkg/dashboard/contribute_landing.go b/src/pkg/dashboard/contribute_landing.go index 65cbf735f4..b48639a1de 100644 --- a/src/pkg/dashboard/contribute_landing.go +++ b/src/pkg/dashboard/contribute_landing.go @@ -546,7 +546,7 @@ code{background:var(--surface-0);padding:var(--sp-1) var(--sp-4);border-radius:v .effective-link{color:var(--cc-accent);text-decoration:none} .effective-link:hover{text-decoration:underline} .effective-section-title{padding:var(--sp-5) var(--sp-7) var(--sp-3);color:var(--text-muted);font-size:var(--fs-xs);text-transform:uppercase;letter-spacing:.08em;font-weight:700} -.lb-row{display:grid;grid-template-columns:56px 1fr 120px 70px 70px 80px 72px;align-items:center;gap:var(--sp-4);padding:10px 20px;border-bottom:1px solid var(--line-subtle);font-size:.85rem} +.lb-row{display:grid;grid-template-columns:56px 1fr 120px 70px 70px 80px 72px 90px;align-items:center;gap:var(--sp-4);padding:10px 20px;border-bottom:1px solid var(--line-subtle);font-size:.85rem} .lb-row:last-child{border-bottom:none} /* Subtle self-highlight for the logged-in viewer's own row: a faint tint + a left accent border, professional not loud. Readability preserved. */ @@ -1540,10 +1540,10 @@ select.admin-act{min-width:0;max-width:100%%} /* Slightly tighter card-internal gutters on the densest rows. */ .clanker-row,.lb-row,.cc-q-item,.cc-tg-item,.cc-tg-head{padding-left:14px;padding-right:14px} - /* Leaderboard: 56px/1fr/120px/70px/70px/80px/72px cannot fit, so the seven cells reflow + /* Leaderboard: the eight desktop cells reflow onto three lines — rank + contributor, then tier + the three counts, then - the sparkline — instead of scrolling sideways. Placement is by child - position because .lb-head and the body rows emit the same seven children in + the sparkline + abandoned count — instead of scrolling sideways. Placement is by child + position because .lb-head and the body rows emit the same eight children in the same order, so the header keeps sitting over the column it labels. The stat tracks stay fixed rem widths for exactly that reason: auto would size per row and the header would drift out of alignment with the numbers. */ @@ -1554,7 +1554,8 @@ select.admin-act{min-width:0;max-width:100%%} .lb-row>:nth-child(4){grid-column:3;grid-row:2} .lb-row>:nth-child(5){grid-column:4;grid-row:2} .lb-row>:nth-child(6){grid-column:5;grid-row:2} - .lb-row>:nth-child(7){grid-column:1/-1;grid-row:3;text-align:left} + .lb-row>:nth-child(7){grid-column:1/3;grid-row:3;text-align:left} + .lb-row>:nth-child(8){grid-column:3/-1;grid-row:3} /* The uppercase, letter-spaced header labels are the widest thing in the stat tracks; drop them a notch so "Findings" fits 3.4rem. */ .lb-head .lb-stat,.lb-head .lb-rank{font-size:var(--fs-2xs)} @@ -3317,6 +3318,7 @@ function lbRow(e,rank){ var tier=tierBadge(e.trust_tier,'tier-lb'); var done=(e.tasks_completed||0); var failed=(e.tasks_failed||0); + var abandoned=(e.abandoned||0); var findings=(e.findings||0); // Subtle self-highlight: the viewer's OWN row (username match, case-insensitive, // humans only — never an agent) gets .lb-row--me + a small "you" chip. Anonymous @@ -3352,6 +3354,7 @@ function lbRow(e,rank){ // per_user_done, matched on github_username via data-user. Empty until metrics // load (renders a flat baseline), never fabricated. +'
' + +'
'+abandoned+'
' +''; } function opsLeaderboardTrendValue(username){ @@ -3385,7 +3388,8 @@ function renderLeaderboard(contribs){ {key:'done',type:'number',value:function(r){return r.entry.tasks_completed;}}, {key:'failed',type:'number',value:function(r){return r.entry.tasks_failed;}}, {key:'findings',type:'number',value:function(r){return r.entry.findings;}}, - {key:'trend',type:'number',value:function(r){return opsLeaderboardTrendValue(r.entry.github_username);}} + {key:'trend',type:'number',value:function(r){return opsLeaderboardTrendValue(r.entry.github_username);}}, + {key:'abandoned',type:'number',value:function(r){return r.entry.abandoned||0;}} ]; var rankedRows=contribs.map(function(e,i){return{entry:e,rank:Number(e.rank||0)||i+1};}); var sortable=opsSortableTable('leaderboard',{rows:rankedRows,columns:lbColumns}); @@ -3396,7 +3400,8 @@ function renderLeaderboard(contribs){ '
'+sortable.header('done','Done')+'
'+ '
'+sortable.header('failed','Failed')+'
'+ '
'+sortable.header('findings','Findings')+'
'+ - '
'+sortable.header('trend','Trend')+'
'; + '
'+sortable.header('trend','Trend')+'
'+ + '
'+sortable.header('abandoned','Abandoned')+'
'; var i; for(i=0;i:nth-child(8){grid-column:3/-1;grid-row:3}"} { + if !strings.Contains(landing, want) { + t.Errorf("landing missing %q", want) + } + } + for _, want := range []string{">Abandoned", "${e.abandoned || 0}"} { + if !strings.Contains(string(dashboard), want) { + t.Errorf("dashboard missing %q", want) + } + } + node, err := exec.LookPath("node") + if err != nil { + t.Skip("node is required for rendering assertions") + } + // Run the shipped renderers with a minimal DOM, rather than a parallel + // implementation of the rendering logic. + common := ` +const assert = require('node:assert/strict'); +const panel = {innerHTML:''}; +const document = {getElementById:()=>panel}; +function esc(s){return String(s);} +function tierBadge(){return '';} +function socialShareControls(){return '';} +function ccRenderLeaderboardSparklines(){} +var ccMeUsername='', lbLastData, ccMetrics=null; +function opsSortableTable(id,opts){return {rows:opts.rows,ariaSort:()=> 'none',header:(key,label)=>label};} +const entries=[{github_username:'alice',rank:1,tasks_completed:10,tasks_failed:2,abandoned:7}, + {github_username:'bob',rank:2,tasks_completed:5}]; +` + landingJS := common + extractJSFunc(t, landing, "function lbRow(e,rank){") + "\n" + + extractJSFunc(t, landing, "function renderLeaderboard(contribs){") + ` +renderLeaderboard(entries); +assert.match(panel.innerHTML, /Abandoned/); +assert.match(lbRow(entries[0],1), /
7<\/div><\/div>$/); +assert.match(lbRow(entries[1],2), /
0<\/div><\/div>$/); +` + dashboardJS := common + ` +const CONTRIBUTOR_AVATAR_PX=32; +function linkedAvatar(){return '';} +function trustTierBadge(){return '';} +function setIfChanged(el,html){el.innerHTML=html;} +` + extractJSFunc(t, string(dashboard), "function renderLeaderboard(entries) {") + ` +renderLeaderboard(entries); +assert.match(panel.innerHTML, />Abandoned<\/th>/); +const rows=panel.innerHTML.match(/([\s\S]*)<\/tbody>/)[1].split('').filter(r=>r.trim()); +assert.equal(rows.length,2); +assert.match(rows[0], />7<\/td>\s*$/); +assert.match(rows[1], />0<\/td>\s*$/); +` + for name, script := range map[string]string{"landing": landingJS, "dashboard": dashboardJS} { + t.Run(name, func(t *testing.T) { + if out, err := exec.Command(node, "-e", script).CombinedOutput(); err != nil { + t.Fatalf("rendering failed: %v\n%s", err, out) + } + }) + } +} diff --git a/src/pkg/dashboard/static-src/css/sparklines-indicators.css b/src/pkg/dashboard/static-src/css/sparklines-indicators.css index b0cf8ce0d0..dbf0dda4e6 100644 --- a/src/pkg/dashboard/static-src/css/sparklines-indicators.css +++ b/src/pkg/dashboard/static-src/css/sparklines-indicators.css @@ -27,6 +27,13 @@ .contrib-status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--status-neutral); } .contrib-status-dot.online { background: var(--status-ok); } .contrib-abandoned { color: var(--status-error); font-weight: 600; } + /* Contributor leaderboard table cells (renderLeaderboard in contributors.js). */ + .contrib-lb-table th, .contrib-lb-table td { padding: var(--sp-4) var(--sp-5); text-align: left; } + .contrib-lb-table th { color: var(--muted); font-weight: 600; } + .contrib-lb-table .contrib-lb-rank { font-weight: 600; color: var(--muted); } + .contrib-lb-table .contrib-lb-num { text-align: right; } + .contrib-lb-table .contrib-lb-failed { color: var(--muted); } + .contrib-lb-table .contrib-lb-failed.has-failures { color: var(--red); } .contrib-card { --contrib-accent: #5aa7ff; --contrib-accent-2: #74df9a; diff --git a/src/pkg/dashboard/static-src/js/contributors.js b/src/pkg/dashboard/static-src/js/contributors.js index 80de8a8a7a..f08f576d9c 100644 --- a/src/pkg/dashboard/static-src/js/contributors.js +++ b/src/pkg/dashboard/static-src/js/contributors.js @@ -453,23 +453,25 @@ ? linkedAvatar(e.github_username, CONTRIBUTOR_AVATAR_PX, `@${e.github_username}`, e.avatar_url) : ``; return ` - ${e.rank} - ${avatarHtml} - @${esc(e.github_username)} - ${trustTierBadge(e.trust_tier)} - ${e.tasks_completed || 0} - ${e.tasks_failed || 0} + ${e.rank} + ${avatarHtml} + @${esc(e.github_username)} + ${trustTierBadge(e.trust_tier)} + ${e.tasks_completed || 0} + ${e.tasks_failed || 0} + ${e.abandoned || 0} `; }).join(''); setIfChanged(panel, `
- +
- - - - - - + + + + + + + ${rows}
#UserTierCompletedFailed#UserTierCompletedFailedAbandoned
diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index f37a4a62a8..16d6833fe3 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -3285,6 +3285,13 @@ .contrib-status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--status-neutral); } .contrib-status-dot.online { background: var(--status-ok); } .contrib-abandoned { color: var(--status-error); font-weight: 600; } + /* Contributor leaderboard table cells (renderLeaderboard in contributors.js). */ + .contrib-lb-table th, .contrib-lb-table td { padding: var(--sp-4) var(--sp-5); text-align: left; } + .contrib-lb-table th { color: var(--muted); font-weight: 600; } + .contrib-lb-table .contrib-lb-rank { font-weight: 600; color: var(--muted); } + .contrib-lb-table .contrib-lb-num { text-align: right; } + .contrib-lb-table .contrib-lb-failed { color: var(--muted); } + .contrib-lb-table .contrib-lb-failed.has-failures { color: var(--red); } .contrib-card { --contrib-accent: #5aa7ff; --contrib-accent-2: #74df9a; @@ -41182,23 +41189,25 @@ ? linkedAvatar(e.github_username, CONTRIBUTOR_AVATAR_PX, `@${e.github_username}`, e.avatar_url) : ``; return ` - ${e.rank} - ${avatarHtml} - @${esc(e.github_username)} - ${trustTierBadge(e.trust_tier)} - ${e.tasks_completed || 0} - ${e.tasks_failed || 0} + ${e.rank} + ${avatarHtml} + @${esc(e.github_username)} + ${trustTierBadge(e.trust_tier)} + ${e.tasks_completed || 0} + ${e.tasks_failed || 0} + ${e.abandoned || 0} `; }).join(''); setIfChanged(panel, `
- +
- - - - - - + + + + + + + ${rows}
#UserTierCompletedFailed#UserTierCompletedFailedAbandoned
diff --git a/src/pkg/dashboard/webstatic/style_ratchet_test.go b/src/pkg/dashboard/webstatic/style_ratchet_test.go index 34a5b7ff10..1a8cb2d5cc 100644 --- a/src/pkg/dashboard/webstatic/style_ratchet_test.go +++ b/src/pkg/dashboard/webstatic/style_ratchet_test.go @@ -26,7 +26,7 @@ type styleRatchetCounts struct { // removes raw styling — but they must not go UP. var styleRatchetBaselines = map[string]styleRatchetCounts{ "operator static/index.html": { - inlineStyles: 1425, + inlineStyles: 1413, rawColors: 135, rawFontSizes: 601, rawPadding: 204,