|
84 | 84 | x-small |
85 | 85 | /> |
86 | 86 | </a> |
| 87 | + <span |
| 88 | + class="use-count" |
| 89 | + :title="`${person.use_count} project ${person.use_count === 1 ? 'use' : 'uses'}`" |
| 90 | + >{{ person.use_count }} {{ person.use_count === 1 ? 'use' : 'uses' }}</span> |
87 | 91 | </div> |
88 | 92 | </div> |
89 | 93 | <div |
@@ -371,16 +375,31 @@ async function searchMatches(row, claimedRoleIds) { |
371 | 375 | } |
372 | 376 | } |
373 | 377 |
|
| 378 | + // Preserves the backend's name-group order (e.g. exact matches before fuzzy), |
| 379 | + // but within each group of identically-named people sorts by project use count descending. |
| 380 | + const sortByUsage = (matches) => { |
| 381 | + const groupOrder = {} |
| 382 | + matches.forEach((p) => { |
| 383 | + const key = p.cached || p.name || '' |
| 384 | + if (!(key in groupOrder)) groupOrder[key] = Object.keys(groupOrder).length |
| 385 | + }) |
| 386 | + return [...matches].sort((a, b) => { |
| 387 | + const groupDiff = groupOrder[a.cached || a.name || ''] - groupOrder[b.cached || b.name || ''] |
| 388 | + if (groupDiff !== 0) return groupDiff |
| 389 | + return (b.use_count || 0) - (a.use_count || 0) |
| 390 | + }) |
| 391 | + } |
| 392 | +
|
374 | 393 | const handleResult = (people) => { |
375 | 394 | if (!firstReturned) { |
376 | 395 | firstReturned = true |
377 | | - row.matches = people |
| 396 | + row.matches = sortByUsage(people) |
378 | 397 | row.isSearching = false |
379 | 398 | claimExistingRole(people) |
380 | 399 | } else { |
381 | 400 | const existingIds = new Set(row.matches.map((p) => p.id)) |
382 | 401 | const incoming = people.filter((p) => !existingIds.has(p.id)) |
383 | | - row.matches = [...row.matches, ...incoming] |
| 402 | + row.matches = sortByUsage([...row.matches, ...incoming]) |
384 | 403 | row.isFuzzySearchPending = false |
385 | 404 | claimExistingRole(incoming) |
386 | 405 | } |
@@ -500,6 +519,11 @@ td { |
500 | 519 | font-size: 0.85em; |
501 | 520 | } |
502 | 521 |
|
| 522 | +.use-count { |
| 523 | + font-size: 0.8em; |
| 524 | + color: var(--text-muted-color); |
| 525 | +} |
| 526 | +
|
503 | 527 | .create-cell { |
504 | 528 | min-width: 250px; |
505 | 529 | } |
|
0 commit comments