fix(panel): 构建记录改由服务端分页列表提供,任何浏览器与管理员都能看到并取消进行中的构建,列表刷新失败保留原行并提示

This commit is contained in:
Lemon-miaow committed 2026-09-25 12:28:22 +08:00
1 parent 9d03386c83
commit 06d5e652c6
16 files changed
+711 -253

No files matched your search

+24
View File
@@ -99,6 +99,30 @@ func (s *PGStore) ListUnfinishedBuilds(ctx context.Context) ([]Build, error) {
if err != nil {
return nil, err
}
return scanBuilds(rows)
}
// ListBuilds pages image_builds newest first. The id breaks created_at ties so
// the pages neither repeat nor skip a row; the Dockerfile column is left empty.
func (s *PGStore) ListBuilds(ctx context.Context, opts ListOpts) ([]Build, int, error) {
const match = ` WHERE $1::text = '' OR id = $1::text OR status::text = lower($1::text)
OR strpos(lower(image_ref), lower($1::text)) > 0`
var total int
if err := s.db.QueryRowContext(ctx, `SELECT count(*) FROM image_builds`+match, opts.Query).Scan(&total); err != nil {
return nil, 0, err
}
rows, err := s.db.QueryContext(ctx, `SELECT id, image_ref, status, '', context_ref, base_image,
requested_by, job_name, log_ref, error, created_at, finished_at, context_digest
FROM image_builds`+match+` ORDER BY created_at DESC, id DESC LIMIT $2 OFFSET $3`,
opts.Query, opts.Limit, opts.Offset)
if err != nil {
return nil, 0, err
}
out, err := scanBuilds(rows)
return out, total, err
}
func scanBuilds(rows *sql.Rows) ([]Build, error) {
defer rows.Close()
var out []Build
for rows.Next() {