Skip to content

Commit

Permalink
Return raw total for top-million scan
Browse files Browse the repository at this point in the history
  • Loading branch information
vbrown608 committed May 24, 2019
1 parent 17ec67e commit 1f3cfef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion checker/totals.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ type AggregatedScan struct {
MTASTSEnforceList []string
}

// TotalsMTASTS returns the number of domains supporting test or enforce mode.
func (a AggregatedScan) TotalMTASTS() int {
return a.MTASTSTesting + a.MTASTSEnforce
}

// PercentMTASTS returns the fraction of domains with MXs that support
// MTA-STS, represented as a float between 0 and 1.
func (a AggregatedScan) PercentMTASTS() float64 {
return (float64(a.MTASTSTesting) + float64(a.MTASTSEnforce)) / float64(a.WithMXs)
return float64(a.TotalMTASTS()) / float64(a.WithMXs)
}

// HandleDomain adds the result of a single domain scan to aggregated stats.
Expand Down
2 changes: 1 addition & 1 deletion db/sqldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (db *SQLDatabase) GetMTASTSStats(source string) (stats.Series, error) {
if err := rows.Scan(&a.Time, &a.WithMXs, &a.MTASTSTesting, &a.MTASTSEnforce); err != nil {
return stats.Series{}, err
}
series[a.Time.UTC()] = a.PercentMTASTS()
series[a.Time.UTC()] = float64(a.TotalMTASTS())
}
return series, nil
}
Expand Down
2 changes: 1 addition & 1 deletion db/sqldb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func TestGetMTASTSStats(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if result[may1] != float64(0.75) || result[may2] != float64(0.5) {
if result[may1] != 3 || result[may2] != 4 {
t.Errorf("Incorrect MTA-STS stats, got %v", result)
}
}
Expand Down

0 comments on commit 1f3cfef

Please sign in to comment.