vole
Clone
Read only, no credentials:
https://rodent.software/git/vole.git
Write over SSH with a registered key:
git clone ssh://git@0.0.0.0:2222/vole.git
A free and open-source forge that lives in your Git repo.
Merge change request 01M70WES5ZZDJ6RP226WB11BBZ: Let people rename and remove their own passkeys
keenan · 2h ago
4b8c9e1d
| 1 | package pageview |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "path/filepath" |
| 6 | "testing" |
| 7 | "time" |
| 8 | ) |
| 9 | |
| 10 | func TestPageViewsAggregateDailyAndUniqueUsers(t *testing.T) { |
| 11 | t.Parallel() |
| 12 | path := filepath.Join(t.TempDir(), "users.db") |
| 13 | if err := touch(path); err != nil { |
| 14 | t.Fatal(err) |
| 15 | } |
| 16 | s, err := Open(path) |
| 17 | if err != nil { |
| 18 | t.Fatal(err) |
| 19 | } |
| 20 | defer s.Close() |
| 21 | |
| 22 | now := time.Date(2026, 10, 26, 12, 0, 0, 0, time.UTC) |
| 23 | for _, account := range []string{"alice", "alice", "bob", ""} { |
| 24 | if err := s.Record(account, now); err != nil { |
| 25 | t.Fatal(err) |
| 26 | } |
| 27 | } |
| 28 | if err := s.Record("alice", now.AddDate(0, 0, -3)); err != nil { |
| 29 | t.Fatal(err) |
| 30 | } |
| 31 | if err := s.Record("bob", now.AddDate(0, 0, -40)); err != nil { |
| 32 | t.Fatal(err) |
| 33 | } |
| 34 | |
| 35 | got, err := s.Stats(now) |
| 36 | if err != nil { |
| 37 | t.Fatal(err) |
| 38 | } |
| 39 | if got.Today.Views != 4 || got.Today.Users != 2 { |
| 40 | t.Fatalf("today = %+v, want 4 views and 2 users", got.Today) |
| 41 | } |
| 42 | if got.Week.Views != 5 || got.Week.Users != 2 { |
| 43 | t.Fatalf("week = %+v, want 5 views and 2 users", got.Week) |
| 44 | } |
| 45 | if got.Month.Views != 5 || got.Month.Users != 2 { |
| 46 | t.Fatalf("month = %+v, want 5 views and 2 users; the 40-day-old row should be excluded", got.Month) |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | func touch(path string) error { |
| 51 | f, err := os.Create(path) |
| 52 | if err != nil { |
| 53 | return err |
| 54 | } |
| 55 | return f.Close() |
| 56 | } |
| 57 |