This repository has been archived by the owner on Jul 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a per-realm-per-user chart on the stats page.
Fixes #799
- Loading branch information
1 parent
7757e0a
commit 435cbc3
Showing
6 changed files
with
271 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package realmadmin | ||
|
||
import ( | ||
"reflect" | ||
"sort" | ||
"testing" | ||
"time" | ||
|
||
"github.com/google/exposure-notifications-verification-server/pkg/database" | ||
) | ||
|
||
func TestFormatStats(t *testing.T) { | ||
now := time.Now().Truncate(24 * time.Hour) | ||
yesterday := now.Add(-24 * time.Hour).Truncate(24 * time.Hour) | ||
tests := []struct { | ||
data []*database.RealmUserStats | ||
names []string | ||
numDays int | ||
}{ | ||
{[]*database.RealmUserStats{}, []string{}, 0}, | ||
{ | ||
[]*database.RealmUserStats{ | ||
{1, "Rocky", 10, now}, | ||
{1, "Bullwinkle", 1, now}, | ||
}, | ||
[]string{"Rocky", "Bullwinkle"}, | ||
1, | ||
}, | ||
{ | ||
[]*database.RealmUserStats{ | ||
{1, "Rocky", 10, yesterday}, | ||
{1, "Rocky", 10, now}, | ||
}, | ||
[]string{"Rocky"}, | ||
2, | ||
}, | ||
} | ||
|
||
for i, test := range tests { | ||
names, format := formatData(test.data) | ||
sort.Strings(test.names) | ||
sort.Strings(names) | ||
if !reflect.DeepEqual(test.names, names) { | ||
t.Errorf("[%d] %v != %v", i, names, test.names) | ||
} | ||
if len(format) != test.numDays { | ||
t.Errorf("[%d] len(format) = %d, expected %d", i, len(format), test.numDays) | ||
} | ||
for _, f := range format { | ||
if len(f) != len(test.names)+1 { | ||
t.Errorf("[%d] len(codesIssued) = %d, expected %d", i, len(f), len(test.names)+1) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters