Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,19 @@ type OrgNode struct {
LastSeenAt string `json:"last_seen_at,omitempty"` // labeled "last dispatch" by clients
}

// OrgBadges contains the blocked/recycle signals displayed on an org node.
// OrgBadges contains the blocked/recycle/activity signals displayed on an org node.
type OrgBadges struct {
BlockedSince string `json:"blocked_since,omitempty"` // RFC3339
Overdue string `json:"overdue,omitempty"` // Go duration text
MissedWakes int `json:"missed_wakes"`
// ActiveJobs is the LIVE count of jobs currently queued or running,
// attributed to this role via ActingOrgRole (gitmoot#1114). This is a
// different, finer-grained signal than OrgRoleActivity.JobsToday (a
// same-UTC-day outcome histogram) — do not collapse the two. ActiveJobs
// answers "is the lane busy right now"; JobsToday answers "what
// happened today". Lets a role whose seat has gone idle still show as
// active while its dispatched workers are mid-flight (gitmoot#1127).
ActiveJobs int `json:"active_jobs,omitempty"`
}

// OrgEscalation is one open read-only escalation.
Expand Down
39 changes: 39 additions & 0 deletions datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,42 @@ func TestWorkflowAdditiveJSONContracts(t *testing.T) {
}
})
}

func TestOrgBadgesActiveJobsAdditiveJSONContract(t *testing.T) {
t.Run("legacy payload omits active_jobs", func(t *testing.T) {
const payload = `{"blocked_since":"2026-07-23T01:31:00Z","overdue":"23m","missed_wakes":2}`
var badges OrgBadges
if err := json.Unmarshal([]byte(payload), &badges); err != nil {
t.Fatalf("unmarshal legacy OrgBadges: %v", err)
}
if badges.ActiveJobs != 0 {
t.Fatalf("legacy OrgBadges.ActiveJobs = %d, want 0", badges.ActiveJobs)
}
got, err := json.Marshal(badges)
if err != nil {
t.Fatalf("marshal legacy OrgBadges: %v", err)
}
if string(got) != payload {
t.Fatalf("legacy OrgBadges JSON = %s, want %s", got, payload)
}
})

t.Run("active jobs round trip", func(t *testing.T) {
badges := OrgBadges{ActiveJobs: 3}
got, err := json.Marshal(badges)
if err != nil {
t.Fatalf("marshal OrgBadges with ActiveJobs: %v", err)
}
const want = `{"missed_wakes":0,"active_jobs":3}`
if string(got) != want {
t.Fatalf("OrgBadges JSON = %s, want %s", got, want)
}
var roundTrip OrgBadges
if err := json.Unmarshal(got, &roundTrip); err != nil {
t.Fatalf("unmarshal OrgBadges: %v", err)
}
if roundTrip.ActiveJobs != 3 {
t.Fatalf("round-trip OrgBadges.ActiveJobs = %d, want 3", roundTrip.ActiveJobs)
}
})
}
Loading