Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software:2222/vole.git

A free and open-source forge that lives in your Git repo.

Turn the user directory into a sortable table

4739664b94c4321b83a2650a3a2486ec090aed64 · Keenan Nemetz · 8d ago · parent c14588ef

Turn the user directory into a sortable table

The list became a table with the same counts, and the column headers
order it: user, repositories, issues, changes, reviews, joining date.
Counts start largest-first and the name A to Z; clicking the active
header flips it. The active column carries aria-sort and an arrow.

The search, the status chips (everyone, active, no longer active), the
order and the page all live in the URL and are carried into every link,
so a view can be bookmarked and paging cannot change the question. It is
all server-side, so it works without JavaScript.

Sorting by a count needs every matched account's summary before the page
is cut, so the index now answers for the whole directory in one grouped
query — ActorSummaries — instead of a lookup for a page of names. That
also drops the per-request name list, so a large roster cannot run into
SQLite's bound-variable limit.

Retired accounts are marked in their row and can be filtered to rather
than living in a separate group, and a roster larger than one page is
covered by a test.

forge/index/profile.go +9−11

@@ -64,22 +64,21 @@ type ActorSummary struct {
64 64 Reviews int
65 65 }
66 66
67 // ActorSummary answers for a whole page of names in one grouped query rather
68 // than one query per row. Names with nothing visible are absent from the map,
69 // which the directory renders as an account with no visible work, not as a zero
70 // somebody should be embarrassed by.
71 func (s *Store) ActorSummary(repoIDs, actors []string) (map[string]ActorSummary, error) {
67 // ActorSummaries answers for every account with visible work in one grouped
68 // query, rather than one query per name. It returns the whole map so a caller can
69 // sort a directory by activity before it pages it: a page of names cannot be
70 // sorted by a count it has not read. Accounts with nothing visible are absent,
71 // which the directory renders as no activity, not as a zero somebody should be
72 // embarrassed by.
73 func (s *Store) ActorSummaries(repoIDs []string) (map[string]ActorSummary, error) {
72 74 out := map[string]ActorSummary{}
73 if len(repoIDs) == 0 || len(actors) == 0 {
75 if len(repoIDs) == 0 {
74 76 return out, nil
75 77 }
76 args := make([]any, 0, len(repoIDs)+len(actors))
78 args := make([]any, 0, len(repoIDs))
77 79 for _, id := range repoIDs {
78 80 args = append(args, id)
79 81 }
80 for _, name := range actors {
81 args = append(args, name)
82 }
83 82 rows, err := s.db.Query(
84 83 `SELECT actor,
85 84 COUNT(DISTINCT repo_id),
@@ -88,7 +87,6 @@ func (s *Store) ActorSummary(repoIDs, actors []string) (map[string]ActorSummary,
88 87 COALESCE(SUM(CASE WHEN type='approval' THEN 1 ELSE 0 END),0)
89 88 FROM events
90 89 WHERE repo_id IN (`+questionMarks(len(repoIDs))+`)
91 AND actor IN (`+questionMarks(len(actors))+`)
92 90 GROUP BY actor`, args...)
93 91 if err != nil {
94 92 return nil, err