Skip to content

Commit

Permalink
feat: show failed dependencies in package results.
Browse files Browse the repository at this point in the history
This table existed in the App Engine version and was temporarily removed,
now it's back! Unlike the "packages broken by this one", the table is
not AJAX, for various reasons. The main reason is that we already have
the list of failed dependencies, so no need for another round trip.
  • Loading branch information
bsiegert committed Mar 9, 2024
1 parent ba10a7f commit 85dd6db
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions pages/bulktracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,14 @@ func (p *PkgDetails) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

res, err := p.DB.GetSingleResult(ctx, resultID)
db, cancel, err := p.DB.BeginReadOnlyTransaction(ctx)
if err != nil {
log.Errorf(ctx, "starting r/o transaction: %v", err)
return
}
defer cancel()

res, err := db.GetSingleResult(ctx, resultID)
if err != nil {
if !errors.Is(err, sql.ErrNoRows) {
log.Errorf(ctx, "GetSingleResult: %v", err)
Expand Down Expand Up @@ -230,22 +237,26 @@ func (p *PkgDetails) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
failedDeps := strings.Split(res.FailedDeps, ",")
fmt.Fprintf(w, "<h2>This package has %d failed dependencies</h2>", len(failedDeps))
// // TODO(bsiegert) Unfortunately, we save a list of package names, not a
// // list of corresponding datastore keys. So we need to fetch them one by
// // one.
// templates.TableBegin(w, "Location", "Package Name", "Status", "Breaks")
// dp := &bulk.Pkg{}
// for _, dep := range p.FailedDeps {
// it := datastore.NewQuery("pkg").Ancestor(buildKey).Filter("PkgName =", dep).Limit(1).Run(ctx)
// key, err := it.Next(dp)
// if err != nil {
// continue
// }
// dp.Key = key.Encode()
// templates.TablePkgs(w, dp)
// }
// io.WriteString(w, templates.TableEnd)
templates.TableBegin(w, "Location", "Package Name", "Status", "Breaks")

sqlBuildID := sql.NullInt64{
Valid: true,
Int64: res.BuildID,
}
rows := make([]ddao.GetSingleResultByPkgNameRow, 0, len(failedDeps))
for _, dep := range failedDeps {
row, err := db.GetSingleResultByPkgName(ctx, ddao.GetSingleResultByPkgNameParams{
PkgName: dep,
BuildID: sqlBuildID,
})
if err != nil {
// Swallow and ignore error.
continue
}
rows = append(rows, row)
}
templates.TablePkgs(w, rows)
templates.TableEnd(w)
}

// Dirs is a handler for a subpage showing all the package directories for a given category.
Expand Down

0 comments on commit 85dd6db

Please sign in to comment.