Fix reader read-aloud races and add rows.Err checks
- reader.js: guard read-aloud against the loading placeholder (bodyReady) and invalidate stale speechSynthesis callbacks with a generation token - storage: check rows.Err() after iterating story-view/content-length reads - metrics: reuse placeholders() instead of duplicating the IN-clause builder
This commit is contained in:
@@ -69,22 +69,20 @@ func StoryViewTotals(ids []int64) map[int64]int {
|
||||
}
|
||||
out[id] = n
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
slog.Error("metrics: story view totals iteration failed", "err", err)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// intInClause builds a "?, ?, …" placeholder string and matching args slice for
|
||||
// a SQL IN (…) over int64 ids.
|
||||
func intInClause(ids []int64) (string, []any) {
|
||||
ph := make([]byte, 0, len(ids)*2)
|
||||
args := make([]any, len(ids))
|
||||
for i, id := range ids {
|
||||
if i > 0 {
|
||||
ph = append(ph, ',')
|
||||
}
|
||||
ph = append(ph, '?')
|
||||
args[i] = id
|
||||
}
|
||||
return string(ph), args
|
||||
return placeholders(len(ids)), args
|
||||
}
|
||||
|
||||
// PathStat is one row of the per-page usage breakdown.
|
||||
|
||||
Reference in New Issue
Block a user