vole
Clone
Read only, no credentials:
https://rodent.software/git/vole.git
Write over SSH with a registered key:
git clone ssh://git@0.0.0.0:2222/vole.git
A free and open-source forge that lives in your Git repo.
Paginate the whole activity feed
c8cdb6accc47af06a3df2b8b5023c21134fdb812 · Keenan Nemetz · 9d ago · parent 4d938fe8
Paginate the whole activity feed Both activity pages stopped at a fixed number of events: the repository feed was truncated at 100, and the instance feed merged 100 per repository and then took 200 before its pager. Anything older was unreachable. Now that issues, changes, comments and state changes are index rows, the whole feed is assembled from the database and paginated: - the repository feed and the instance feed keep the whole sorted, filtered list, and both show 50 events per page; - the repository feed gains a pager (it had none), and the instance pager now reaches all history; - the kind/actor/assignee filters travel through the page links, so paging never widens the feed; - the repository pager swaps the `#activity-feed` fragment over HTMX like the chips and the filter form, and the page links are plain hrefs when JavaScript is not there; - the feed reads comment summaries (parent, id, author, created) rather than every comment body it will not render. The home rail still asks for a bounded feed, so it keeps its handful of events. The feed is assembled in memory per request, so a page costs O(history) instead of O(page); that is the accepted trade for now, and a SQL event stream is the follow-up if a large history makes it visible.
forge/index/comments.go +35−1
| @@ -97,7 +97,41 @@ func (s *Store) Comments(repoID, kind, parent string) ([]CommentRow, error) { | |||
| 97 | 97 | return scanComments(rows) | |
| 98 | 98 | } | |
| 99 | 99 | ||
| 100 | // scanComments reads the columns Comments and CommentsForRepo both select. | ||
| 100 | // CommentSummary is one comment as a feed names it: who, when, and which | ||
| 101 | // thread. It carries no body and no anchor. | ||
| 102 | type CommentSummary struct { | ||
| 103 | Parent string | ||
| 104 | ID string | ||
| 105 | Author string | ||
| 106 | Created time.Time | ||
| 107 | } | ||
| 108 | |||
| 109 | // CommentSummaries returns every comment of one kind in a repository, for a feed | ||
| 110 | // that groups them by parent. It reads no body: a feed over the whole history | ||
| 111 | // must not pay for text it will not render. | ||
| 112 | func (s *Store) CommentSummaries(repoID, kind string) ([]CommentSummary, error) { | ||
| 113 | rows, err := s.db.Query( | ||
| 114 | `SELECT parent, id, author, created FROM comments | ||
| 115 | WHERE repo_id=? AND kind=? ORDER BY parent, id`, | ||
| 116 | repoID, kind) | ||
| 117 | if err != nil { | ||
| 118 | return nil, err | ||
| 119 | } | ||
| 120 | defer rows.Close() | ||
| 121 | var out []CommentSummary | ||
| 122 | for rows.Next() { | ||
| 123 | var c CommentSummary | ||
| 124 | var created int64 | ||
| 125 | if err := rows.Scan(&c.Parent, &c.ID, &c.Author, &created); err != nil { | ||
| 126 | return nil, err | ||
| 127 | } | ||
| 128 | c.Created = unixTime(created) | ||
| 129 | out = append(out, c) | ||
| 130 | } | ||
| 131 | return out, rows.Err() | ||
| 132 | } | ||
| 133 | |||
| 134 | // scanComments reads the columns Comments selects. | ||
| 101 | 135 | func scanComments(rows *sql.Rows) ([]CommentRow, error) { | |
| 102 | 136 | var out []CommentRow | |
| 103 | 137 | for rows.Next() { | |