Skip to content

Commit a96034a

Browse files
committed
dashboard/app: fix bugs in handleCoverageReports
1. Set coverage db. 2. Read host from request, not request.URL.
1 parent 2bfec9c commit a96034a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

dashboard/app/reporting_email.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ func (cfg *EmailConfig) Validate() error {
110110
// Assuming it is called June 15, the monthly report will cover April-May diff.
111111
func handleCoverageReports(w http.ResponseWriter, r *http.Request) {
112112
ctx := r.Context()
113-
curHostPort := r.URL.Host
113+
if coverageDBClient != nil { // initialized in prod deployment, nil in tests
114+
ctx = SetCoverageDBClient(r.Context(), coverageDBClient)
115+
}
114116
targetDate := civil.DateOf(timeNow(ctx)).AddMonths(-1)
115117
periods, err := coveragedb.GenNPeriodsTill(2, targetDate, "month")
116118
if err != nil {
@@ -133,7 +135,7 @@ func handleCoverageReports(w http.ResponseWriter, r *http.Request) {
133135
wg.Add(1)
134136
go func() {
135137
defer wg.Done()
136-
if err := sendNsCoverageReport(ctx, nsName, emailTo, curHostPort, periods, minDrop); err != nil {
138+
if err := sendNsCoverageReport(ctx, nsName, emailTo, r.Host, periods, minDrop); err != nil {
137139
msg := fmt.Sprintf("error generating coverage report for ns '%s': %s", nsName, err.Error())
138140
log.Errorf(ctx, "%s", msg)
139141
return

0 commit comments

Comments
 (0)