Skip to content

Commit

Permalink
Merge pull request #165 from ComradeProgrammer/154
Browse files Browse the repository at this point in the history
add number tests ran in the summary table
  • Loading branch information
medyagh authored Sep 27, 2024
2 parents 4c4c1c9 + 010bf8c commit 8b1e14a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/db/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,15 @@ func (m *Postgres) GetEnvCharts(env string, testsInTop int) (map[string]interfac
LIMIT 1
), temp AS (
SELECT TestName,
SUM(CASE WHEN Result = 'fail' AND TestTime > (SELECT Date FROM recentCutoff) THEN 1 ELSE 0 END) As FailedTestNum,
SUM(CASE WHEN TestTime > (SELECT Date FROM recentCutoff) THEN 1 ELSE 0 END) As TotalTestNum,
ROUND(COALESCE(AVG(CASE WHEN TestTime > (SELECT Date FROM recentCutoff) THEN CASE WHEN Result = 'fail' THEN 1 ELSE 0 END END) * 100, 0), 2) AS RecentFlakePercentage,
ROUND(COALESCE(AVG(CASE WHEN TestTime <= (SELECT Date FROM recentCutoff) AND TestTime > (SELECT Date FROM prevCutoff) THEN CASE WHEN Result = 'fail' THEN 1 ELSE 0 END END) * 100, 0), 2) AS PrevFlakePercentage
FROM %s
GROUP BY TestName
ORDER BY RecentFlakePercentage DESC
)
SELECT TestName, RecentFlakePercentage, RecentFlakePercentage - PrevFlakePercentage AS GrowthRate
SELECT TestName, RecentFlakePercentage, RecentFlakePercentage - PrevFlakePercentage AS GrowthRate, FailedTestNum, TotalTestNum
FROM temp
ORDER BY RecentFlakePercentage DESC;
`, viewName, viewName)
Expand Down
4 changes: 3 additions & 1 deletion pkg/handler/flake_chart.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@
for (let i = 0; i < recentFlakePercentTable.length; i++) {
const {
testName,
failedTestNum,
totalTestNum,
recentFlakePercentage,
growthRate
} = recentFlakePercentTable[i];
const row = document.createElement("tr");
row.appendChild(createCell("td", "" + (i + 1))).style.textAlign = "center";
row.appendChild(createCell("td", `<a href="${window.location.pathname}?env=${query.env}&test=${testName}">${testName}</a>`));
row.appendChild(createCell("td", recentFlakePercentage + "%")).style.textAlign = "right";
row.appendChild(createCell("td", recentFlakePercentage + "% (" + failedTestNum + "/" + totalTestNum + ")")).style.textAlign = "right";
row.appendChild(createCell("td", `<span style="color: ${growthRate === 0 ? "black" : (growthRate > 0 ? "red" : "green")}">${growthRate > 0 ? '+' + growthRate : growthRate}%</span>`));
tableBody.appendChild(row);
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ type DBFlakeRow struct {
TestName string `json:"testName"`
RecentFlakePercentage float32 `json:"recentFlakePercentage"`
GrowthRate float32 `json:"growthRate"`
FailedTestNum float32 `json:"failedTestNum"`
TotalTestNum float32 `json:"totalTestNum"`
}

// DBFlakeBy represents a "row" in the flake rate by _ of top 10 of recent test flakiness charts
Expand Down

0 comments on commit 8b1e14a

Please sign in to comment.