From cdd39862e70e838342c18dcfff9967b02de640bc Mon Sep 17 00:00:00 2001 From: mendezr Date: Fri, 30 Oct 2026 18:54:03 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20feature:=20show=20abandoned=20P?= =?UTF-8?q?R=20counts=20on=20contributor=20leaderboards?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Expose the persisted abandoned count without changing rankings, and append columns to the dashboard and contribute landing standings. Cover JSON values, legacy zero defaults, and both renderers. Hive-Run: hivecommons/hive#15796 Hive-Plan: issue-15796-leaderboard-columns Hive-Spec: issue-15796#acceptance Signed-off-by: mendezr --- changelog.d/added-abandoned-leaderboards.md | 1 + src/pkg/dashboard/contribute_landing.go | 19 +-- src/pkg/dashboard/contribute_leaderboard.go | 2 + .../contribute_leaderboard_abandoned_test.go | 117 ++++++++++++++++++ src/pkg/dashboard/contribute_profiles.go | 2 + src/pkg/dashboard/static/index.html | 2 + 6 files changed, 136 insertions(+), 7 deletions(-) create mode 100644 changelog.d/added-abandoned-leaderboards.md create mode 100644 src/pkg/dashboard/contribute_leaderboard_abandoned_test.go 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 e810c5f254..05bc652501 100644 --- a/src/pkg/dashboard/contribute_landing.go +++ b/src/pkg/dashboard/contribute_landing.go @@ -545,7 +545,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. */ @@ -1539,10 +1539,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. */ @@ -1553,7 +1553,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)} @@ -3269,6 +3270,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 @@ -3304,6 +3306,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){ @@ -3337,7 +3340,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}); @@ -3348,7 +3352,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/contribute_profiles.go b/src/pkg/dashboard/contribute_profiles.go index 9e14b53105..d275e7173a 100644 --- a/src/pkg/dashboard/contribute_profiles.go +++ b/src/pkg/dashboard/contribute_profiles.go @@ -189,6 +189,8 @@ type ContributorProfile struct { LastActive string `json:"last_active,omitempty"` LastCompletedTask *WSTaskAssign `json:"last_completed_task,omitempty"` RateLimits ContributorRateLimits `json:"rate_limits"` + // Abandoned counts this contributor's PRs adopted by the hive, once per PR. + Abandoned int `json:"abandoned"` // LabelInterests is the contributor's OPT-IN list of GitHub issue labels they // want to help with (issue #2637) — e.g. a contributor with an NVIDIA machine // subscribes to "nvidia" so nvidia-labelled work surfaces first for them. It is diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index a918d7bacd..be06071edc 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -40587,6 +40587,7 @@ ${trustTierBadge(e.trust_tier)} ${e.tasks_completed || 0} ${e.tasks_failed || 0} + ${e.abandoned || 0} `; }).join(''); setIfChanged(panel, `
@@ -40598,6 +40599,7 @@ Tier Completed Failed + Abandoned ${rows} From 0c0aa58de7395541437db34bd50964d418e94fd7 Mon Sep 17 00:00:00 2001 From: mendezr Date: Fri, 30 Oct 2026 19:07:53 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20fix:=20repair=20leaderboard?= =?UTF-8?q?=20fixtures=20and=20dashboard=20source=20parity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mendezr --- src/pkg/dashboard/contribute_leaderboard_abandoned_test.go | 5 +++-- src/pkg/dashboard/static-src/js/contributors.js | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pkg/dashboard/contribute_leaderboard_abandoned_test.go b/src/pkg/dashboard/contribute_leaderboard_abandoned_test.go index 3ef0d8b5b4..6aeadf89fe 100644 --- a/src/pkg/dashboard/contribute_leaderboard_abandoned_test.go +++ b/src/pkg/dashboard/contribute_leaderboard_abandoned_test.go @@ -14,12 +14,13 @@ func TestLeaderboardAPIAbandoned(t *testing.T) { s := newDossierTestServer(t) // Seed persisted profiles, as written by adoption accounting. Keep this // reader test independent of the accounting writer's reconciliation rules. + // Include contributor IDs so listContributorProfiles accepts both records. if err := os.MkdirAll(getContributorsDir(), 0o755); err != nil { t.Fatal(err) } for name, profile := range map[string]string{ - "alice": `{"github_username":"alice","trust_tier":"contributor","total_tasks_completed":10,"abandoned":7}`, - "bob": `{"github_username":"bob","trust_tier":"contributor","total_tasks_completed":5}`, + "alice": `{"github_username":"alice","contributor_id":"c-alice","trust_tier":"contributor","total_tasks_completed":10,"abandoned":7}`, + "bob": `{"github_username":"bob","contributor_id":"c-bob","trust_tier":"contributor","total_tasks_completed":5}`, } { if err := os.WriteFile(filepath.Join(getContributorsDir(), name+".json"), []byte(profile), 0o600); err != nil { t.Fatal(err) diff --git a/src/pkg/dashboard/static-src/js/contributors.js b/src/pkg/dashboard/static-src/js/contributors.js index 3c1f4af243..43abec9267 100644 --- a/src/pkg/dashboard/static-src/js/contributors.js +++ b/src/pkg/dashboard/static-src/js/contributors.js @@ -449,6 +449,7 @@ ${trustTierBadge(e.trust_tier)} ${e.tasks_completed || 0} ${e.tasks_failed || 0} + ${e.abandoned || 0} `; }).join(''); setIfChanged(panel, `
@@ -460,6 +461,7 @@ Tier Completed Failed + Abandoned ${rows}