Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dashboard/app: show manager coverage #5641

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions dashboard/app/graphs.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ func handleFoundBugsGraph(c context.Context, w http.ResponseWriter, r *http.Requ
return serveTemplate(w, "graph_histogram.html", data)
}

type funcStyleBodyJS func(ctx context.Context, projectID, ns, subsystem string, periods []coveragedb.TimePeriod,
) (template.CSS, template.HTML, template.HTML, error)
type funcStyleBodyJS func(ctx context.Context, projectID, ns, subsystem, manager string,
periods []coveragedb.TimePeriod) (template.CSS, template.HTML, template.HTML, error)

func handleCoverageHeatmap(c context.Context, w http.ResponseWriter, r *http.Request) error {
return handleHeatmap(c, w, r, cover.DoHeatMapStyleBodyJS)
Expand All @@ -211,6 +211,7 @@ func handleHeatmap(c context.Context, w http.ResponseWriter, r *http.Request, f
return err
}
ss := r.FormValue("subsystem")
manager := r.FormValue("manager")

periodType := r.FormValue("period")
if periodType == "" {
Expand All @@ -236,7 +237,7 @@ func handleHeatmap(c context.Context, w http.ResponseWriter, r *http.Request, f
}
var style template.CSS
var body, js template.HTML
if style, body, js, err = f(c, "syzkaller", hdr.Namespace, ss, periods); err != nil {
if style, body, js, err = f(c, "syzkaller", hdr.Namespace, ss, manager, periods); err != nil {
return fmt.Errorf("failed to generate heatmap: %w", err)
}
return serveTemplate(w, "custom_content.html", struct {
Expand Down
28 changes: 16 additions & 12 deletions pkg/cover/heatmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ func filesCoverageToTemplateData(fCov []*fileCoverageWithDetails) *templateHeatm
return &res
}

func filesCoverageWithDetailsStmt(ns, subsystem string, timePeriod coveragedb.TimePeriod) spanner.Statement {
func filesCoverageWithDetailsStmt(ns, subsystem, manager string, timePeriod coveragedb.TimePeriod) spanner.Statement {
if manager == "" {
manager = "*"
}
stmt := spanner.Statement{
SQL: `
select
Expand All @@ -170,22 +173,23 @@ from merge_history
join file_subsystems
on merge_history.namespace = file_subsystems.namespace and files.filepath = file_subsystems.filepath
where
merge_history.namespace=$1 and dateto=$2 and duration=$3 and manager='*'`,
merge_history.namespace=$1 and dateto=$2 and duration=$3 and manager=$4`,
Params: map[string]interface{}{
"p1": ns,
"p2": timePeriod.DateTo,
"p3": timePeriod.Days,
"p4": manager,
},
}
if subsystem != "" {
stmt.SQL += " and $4=ANY(subsystems)"
stmt.Params["p4"] = subsystem
stmt.SQL += " and $5=ANY(subsystems)"
stmt.Params["p5"] = subsystem
}
return stmt
}

func filesCoverageWithDetails(ctx context.Context, projectID, ns, subsystem string, timePeriods []coveragedb.TimePeriod,
) ([]*fileCoverageWithDetails, error) {
func filesCoverageWithDetails(ctx context.Context, projectID, ns, subsystem, manager string,
timePeriods []coveragedb.TimePeriod) ([]*fileCoverageWithDetails, error) {
client, err := spannerclient.NewClient(ctx, projectID)
if err != nil {
return nil, fmt.Errorf("spanner.NewClient() failed: %s", err.Error())
Expand All @@ -194,7 +198,7 @@ func filesCoverageWithDetails(ctx context.Context, projectID, ns, subsystem stri

res := []*fileCoverageWithDetails{}
for _, timePeriod := range timePeriods {
stmt := filesCoverageWithDetailsStmt(ns, subsystem, timePeriod)
stmt := filesCoverageWithDetailsStmt(ns, subsystem, manager, timePeriod)
iter := client.Single().Query(ctx, stmt)
defer iter.Stop()
for {
Expand Down Expand Up @@ -239,19 +243,19 @@ func stylesBodyJSTemplate(templData *templateHeatmap,
template.HTML(js.Bytes()), nil
}

func DoHeatMapStyleBodyJS(ctx context.Context, projectID, ns, subsystem string, periods []coveragedb.TimePeriod,
) (template.CSS, template.HTML, template.HTML, error) {
covAndDates, err := filesCoverageWithDetails(ctx, projectID, ns, subsystem, periods)
func DoHeatMapStyleBodyJS(ctx context.Context, projectID, ns, subsystem, manager string,
periods []coveragedb.TimePeriod) (template.CSS, template.HTML, template.HTML, error) {
covAndDates, err := filesCoverageWithDetails(ctx, projectID, ns, subsystem, manager, periods)
if err != nil {
return "", "", "", fmt.Errorf("failed to filesCoverageWithDetails: %w", err)
}
templData := filesCoverageToTemplateData(covAndDates)
return stylesBodyJSTemplate(templData)
}

func DoSubsystemsHeatMapStyleBodyJS(ctx context.Context, projectID, ns, subsystem string,
func DoSubsystemsHeatMapStyleBodyJS(ctx context.Context, projectID, ns, subsystem, manager string,
periods []coveragedb.TimePeriod) (template.CSS, template.HTML, template.HTML, error) {
covWithDetails, err := filesCoverageWithDetails(ctx, projectID, ns, subsystem, periods)
covWithDetails, err := filesCoverageWithDetails(ctx, projectID, ns, subsystem, manager, periods)
if err != nil {
panic(err)
}
Expand Down
Loading