fix(web): detail row lookup walks all pages of the Site read (#144)

This commit is contained in:
2026-08-21 19:42:45 +07:00
parent 14990bde21
commit 09a094ca67
2 changed files with 54 additions and 14 deletions
+21 -13
View File
@@ -36,27 +36,35 @@ type seriesDetailView struct {
// adminSeriesDetail renders one Series' page, keyed by the composite
// "<site>:<series_id>" the list row already shows. The row is read through
// the list's own SeriesPage read narrowed to the key's Site: the admin
// projection is the privacy boundary, and a second single-row read would be a
// second definition of it.
// ponytail: one 50-row page scan per detail view; a keyed read alongside
// SeriesPage when the library outgrows the page size.
// projection is the privacy boundary, and a dedicated single-row read would
// be a second definition of it.
// ponytail: a page scan per detail view, one query per page of the Site's
// rows up to the window total; a keyed read alongside SeriesPage when the
// library outgrows the page size.
func (h *Handler) adminSeriesDetail(w http.ResponseWriter, r *http.Request) {
site, seriesID, ok := strings.Cut(r.PathValue("key"), ":")
if !ok || site == "" || seriesID == "" {
http.NotFound(w, r)
return
}
page, err := h.store.SeriesPage(store.SeriesFilter{Site: site})
if err != nil {
log.Printf("series detail %s: %v", site+":"+seriesID, err)
http.Error(w, "internal error", http.StatusInternalServerError)
return
}
for i := range page.Rows {
if page.Rows[i].SeriesID == seriesID {
h.renderAdmin(w, adminView{Page: "series-detail", Detail: h.seriesDetailView(page.Rows[i])})
seen := 0
for page := 1; ; page++ {
p, err := h.store.SeriesPage(store.SeriesFilter{Site: site, Page: page})
if err != nil {
log.Printf("series detail %s: %v", site+":"+seriesID, err)
http.Error(w, "internal error", http.StatusInternalServerError)
return
}
seen += len(p.Rows)
for i := range p.Rows {
if p.Rows[i].SeriesID == seriesID {
h.renderAdmin(w, adminView{Page: "series-detail", Detail: h.seriesDetailView(p.Rows[i])})
return
}
}
if seen >= p.Total {
break
}
}
http.NotFound(w, r)
}