aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkg/app/handler/categories/show.go2
-rw-r--r--pkg/app/handler/maintainer/show.go2
-rw-r--r--pkg/app/handler/packages/components/bugs.templ12
-rw-r--r--pkg/app/handler/packages/show.go2
-rw-r--r--pkg/app/handler/packages/show.templ8
-rw-r--r--pkg/app/utils/bugs.go10
-rw-r--r--pkg/models/bug.go18
-rw-r--r--pkg/portage/bugs/bugs.go2
-rw-r--r--pkg/portage/maintainers/update.go2
9 files changed, 38 insertions, 20 deletions
diff --git a/pkg/app/handler/categories/show.go b/pkg/app/handler/categories/show.go
index 5e9151b..a7dad6b 100644
--- a/pkg/app/handler/categories/show.go
+++ b/pkg/app/handler/categories/show.go
@@ -146,7 +146,7 @@ func ShowSecurity(w http.ResponseWriter, r *http.Request) {
DistinctOn("id::INT").
Column("id", "summary", "component", "assignee").
OrderExpr("id::INT").
- Where("component = ?", "Vulnerabilities").
+ Where("component = ?", models.BugComponentVulnerabilities).
Where("id IN (?)",
database.DBCon.Model((*models.PackageToBug)(nil)).
Column("bug_id").
diff --git a/pkg/app/handler/maintainer/show.go b/pkg/app/handler/maintainer/show.go
index dc80ec2..410854b 100644
--- a/pkg/app/handler/maintainer/show.go
+++ b/pkg/app/handler/maintainer/show.go
@@ -240,7 +240,7 @@ func ShowSecurity(w http.ResponseWriter, r *http.Request) {
Column("id", "summary", "component", "assignee").
OrderExpr("id::INT").
With("wanted", query).
- Where("component = ?", "Vulnerabilities").
+ Where("component = ?", models.BugComponentVulnerabilities).
Where("id IN (?)",
database.DBCon.Model((*models.PackageToBug)(nil)).
Column("bug_id").
diff --git a/pkg/app/handler/packages/components/bugs.templ b/pkg/app/handler/packages/components/bugs.templ
index ee49df2..b601903 100644
--- a/pkg/app/handler/packages/components/bugs.templ
+++ b/pkg/app/handler/packages/components/bugs.templ
@@ -3,11 +3,11 @@ package components
import "soko/pkg/models"
import "strconv"
-templ bugsList(title, component string, bugs []*models.Bug, titleClass, id string) {
+templ bugsList(title string, component models.BugComponent, bugs []*models.Bug, titleClass, id string) {
<h3 id={ id } class={ titleClass }>{ title }</h3>
<ul class="list-group">
for _, bug := range bugs {
- if bug.Component == component {
+ if bug.MatchesComponent(component) {
<li class="list-group-item">
<div class="row">
<div class="col-md-12">
@@ -36,13 +36,13 @@ templ Bugs(atom string, generalCount, stabilizationCount, keywordingCount int, b
<div class="col-md-9">
if len(bugs) > 0 {
if generalCount > 0 {
- @bugsList("Bug Reports", "Current packages", bugs, "mb-4", "packages")
+ @bugsList("Bug Reports", models.BugComponentGeneral, bugs, "mb-4", "packages")
}
if stabilizationCount > 0 {
- @bugsList("Stabilization Bug Reports", "Stabilization", bugs, "my-4", "stabilization")
+ @bugsList("Stabilization Bug Reports", models.BugComponentStabilization, bugs, "my-4", "stabilization")
}
if keywordingCount > 0 {
- @bugsList("Keywording Bug Reports", "Keywording", bugs, "my-4", "keywording")
+ @bugsList("Keywording Bug Reports", models.BugComponentKeywording, bugs, "my-4", "keywording")
}
} else {
<div class="row pt-5">
@@ -123,7 +123,7 @@ templ SecurityBugs(atom string, bugs []*models.Bug) {
<div class="row">
<div class="col-md-9">
if len(bugs) > 0 {
- @bugsList("Security Bug Reports", "Vulnerabilities", bugs, "mb-4", "security")
+ @bugsList("Security Bug Reports", models.BugComponentVulnerabilities, bugs, "mb-4", "security")
} else {
<div class="row pt-5">
<div class="col-md-4">
diff --git a/pkg/app/handler/packages/show.go b/pkg/app/handler/packages/show.go
index b5c017f..a3c71b7 100644
--- a/pkg/app/handler/packages/show.go
+++ b/pkg/app/handler/packages/show.go
@@ -216,7 +216,7 @@ func changelogJSON(w http.ResponseWriter, r *http.Request) {
func countBugs(gpackage *models.Package) (securityBugs, nonSecurityBugs int) {
for _, bug := range gpackage.Bugs {
- if bug.Component == "Vulnerabilities" {
+ if bug.Component == string(models.BugComponentVulnerabilities) {
securityBugs++
} else {
nonSecurityBugs++
diff --git a/pkg/app/handler/packages/show.templ b/pkg/app/handler/packages/show.templ
index fa3b33f..6718ae0 100644
--- a/pkg/app/handler/packages/show.templ
+++ b/pkg/app/handler/packages/show.templ
@@ -98,7 +98,7 @@ func collectAllBugs(pkg *models.Package) (atom string, generalCount, stabilizati
bugs = make([]*models.Bug, 0, len(pkg.Bugs))
handled := make(map[string]struct{}, len(pkg.Bugs))
for _, bug := range pkg.Bugs {
- if bug.Component == "Current packages" {
+ if bug.Component != string(models.BugComponentVulnerabilities) {
generalCount++
bugs = append(bugs, bug)
handled[bug.Id] = struct{}{}
@@ -109,10 +109,10 @@ func collectAllBugs(pkg *models.Package) (atom string, generalCount, stabilizati
if _, found := handled[bug.Id]; found {
continue
}
- if bug.Component == "Stabilization" {
+ if bug.Component == string(models.BugComponentStabilization) {
stabilizationCount++
bugs = append(bugs, bug)
- } else if bug.Component == "Keywording" {
+ } else if bug.Component == string(models.BugComponentKeywording) {
keywordingCount++
bugs = append(bugs, bug)
}
@@ -125,7 +125,7 @@ func collectAllBugs(pkg *models.Package) (atom string, generalCount, stabilizati
func collectSecurityBugs(pkg *models.Package) (string, []*models.Bug) {
bugs := make([]*models.Bug, 0, len(pkg.Bugs))
for _, bug := range pkg.Bugs {
- if bug.Component == "Vulnerabilities" {
+ if bug.Component == string(models.BugComponentVulnerabilities) {
bugs = append(bugs, bug)
}
}
diff --git a/pkg/app/utils/bugs.go b/pkg/app/utils/bugs.go
index d840541..a49f21d 100644
--- a/pkg/app/utils/bugs.go
+++ b/pkg/app/utils/bugs.go
@@ -7,14 +7,14 @@ import (
func CountBugsCategories(bugs []*models.Bug) (generalCount, stabilizationCount, keywordingCount int) {
for _, bug := range bugs {
switch bug.Component {
- case "Current packages":
- generalCount++
- case "Stabilization":
+ case string(models.BugComponentVulnerabilities):
+ continue
+ case string(models.BugComponentStabilization):
stabilizationCount++
- case "Keywording":
+ case string(models.BugComponentKeywording):
keywordingCount++
default:
- continue
+ generalCount++
}
}
return
diff --git a/pkg/models/bug.go b/pkg/models/bug.go
index 15bdaf5..1329631 100644
--- a/pkg/models/bug.go
+++ b/pkg/models/bug.go
@@ -1,5 +1,14 @@
package models
+type BugComponent string
+
+const (
+ BugComponentVulnerabilities BugComponent = "Vulnerabilities"
+ BugComponentStabilization BugComponent = "Stabilization"
+ BugComponentKeywording BugComponent = "Keywording"
+ BugComponentGeneral BugComponent = ""
+)
+
type Bug struct {
Id string `pg:",pk"`
Product string
@@ -20,3 +29,12 @@ type VersionToBug struct {
VersionId string
BugId string
}
+
+func (b *Bug) MatchesComponent(component BugComponent) bool {
+ if component != BugComponentGeneral {
+ return b.Component == string(component)
+ }
+ return b.Component != string(BugComponentVulnerabilities) &&
+ b.Component != string(BugComponentStabilization) &&
+ b.Component != string(BugComponentKeywording)
+}
diff --git a/pkg/portage/bugs/bugs.go b/pkg/portage/bugs/bugs.go
index 3e803b8..a561f48 100644
--- a/pkg/portage/bugs/bugs.go
+++ b/pkg/portage/bugs/bugs.go
@@ -271,7 +271,7 @@ func updateCategoriesInfo() {
err := database.DBCon.Model((*models.PackageToBug)(nil)).
ColumnExpr("SPLIT_PART(package_atom, '/', 1) as name").
ColumnExpr("COUNT(DISTINCT bug_id) as bugs").
- ColumnExpr("COUNT(DISTINCT bug_id) FILTER(WHERE component = ?) as security_bugs", "Vulnerabilities").
+ ColumnExpr("COUNT(DISTINCT bug_id) FILTER(WHERE component = ?) as security_bugs", models.BugComponentVulnerabilities).
Join("JOIN bugs").JoinOn("package_to_bug.bug_id = bugs.id").
Where("NULLIF(package_atom, '') IS NOT NULL").
Where(`package_atom LIKE '%/%'`).
diff --git a/pkg/portage/maintainers/update.go b/pkg/portage/maintainers/update.go
index 306d9d8..297bf14 100644
--- a/pkg/portage/maintainers/update.go
+++ b/pkg/portage/maintainers/update.go
@@ -142,7 +142,7 @@ func countBugs(packages []*models.Package) (securityBugs, nonSecurityBugs int) {
}
for _, bug := range allBugs {
- if bug.Component == "Vulnerabilities" {
+ if bug.Component == string(models.BugComponentVulnerabilities) {
securityBugs++
} else {
nonSecurityBugs++