Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Remove page-view tracking

0a12642f6c01236d1fbd4ee06aaa2bd2283c6bf0 · Keenan Nemetz · 3d ago · parent 8f6548a6

Remove page-view tracking

Counting a page wrote a row to instance.db on every successful HTML GET, so
reading the instance contended with CI and the merge worker for the one
write lock. The counters answered one status page and were not part of what
a restore has to keep, so the feature is gone rather than moved.

The status overview loses its page-view card and table; the rest of the
Admin page is unchanged. An instance that recorded views keeps the old
page_views table in instance.db, which nothing reads.

Refs #398

server/status_test.go +3−40

@@ -4,7 +4,6 @@ import (
4 4 "net/http"
5 5 "strings"
6 6 "testing"
7 "time"
8 7
9 8 "rodent.software/vole/forge/config"
10 9 "rodent.software/vole/forge/repo"
@@ -29,7 +28,7 @@ func TestAdminOverviewSummarizesTheInstance(t *testing.T) {
29 28 }
30 29 for _, want := range []string{
31 30 "Overview", "Storage", "Runners", "Configuration", "Storage used", "Free space",
32 "Users", "Repositories", "Page views", "Today (UTC)",
31 "Users", "Repositories",
33 32 "Recent admin activity", "Read the full audit log",
34 33 } {
35 34 if !strings.Contains(body, want) {
@@ -83,42 +82,6 @@ func TestAdminConfigurationShowsToAdmins(t *testing.T) {
83 82 }
84 83 }
85 84
86 func TestAdminPagesAreNotCountedAsPageViews(t *testing.T) {
87 t.Parallel()
88 f := newFixture(t)
89
90 for i := 0; i < 3; i++ {
91 if code, _ := f.get("/"); code != 200 {
92 t.Fatalf("anonymous page %d = %d", i, code)
93 }
94 }
95 _, cookie := f.browserSession(t, f.ownerID)
96 if resp, _ := f.browserGet(t, "/", cookie); resp.StatusCode != 200 {
97 t.Fatalf("signed-in page = %d", resp.StatusCode)
98 }
99
100 stats, err := f.srv.Web.PageViews.Stats(time.Now().UTC())
101 if err != nil {
102 t.Fatal(err)
103 }
104 if stats.Today.Views != 4 || stats.Today.Users != 1 {
105 t.Fatalf("today = %+v, want 4 views and 1 signed-in user", stats.Today)
106 }
107
108 // The status page must not count itself, or a monitor turns the metric into
109 // a measure of polling.
110 if code, _ := f.adminGet(t, "/-/admin"); code != 200 {
111 t.Fatalf("status = %d", code)
112 }
113 stats, err = f.srv.Web.PageViews.Stats(time.Now().UTC())
114 if err != nil {
115 t.Fatal(err)
116 }
117 if stats.Today.Views != 4 {
118 t.Fatalf("status page changed the view count to %d", stats.Today.Views)
119 }
120 }
121
122 85 func TestAdminTabsSplitTheSections(t *testing.T) {
123 86 t.Parallel()
124 87 f := newFixture(t)
@@ -133,7 +96,7 @@ func TestAdminTabsSplitTheSections(t *testing.T) {
133 96 if code != 200 || !strings.Contains(storage, "Repositories") || !strings.Contains(storage, "LFS and build objects") {
134 97 t.Fatalf("storage tab = %d:\n%s", code, storage)
135 98 }
136 for _, gone := range []string{"Page views", "Runners and queue", "Instance and access"} {
99 for _, gone := range []string{"Runners and queue", "Instance and access"} {
137 100 if strings.Contains(storage, gone) {
138 101 t.Fatalf("storage tab shows %q:", gone)
139 102 }
@@ -143,7 +106,7 @@ func TestAdminTabsSplitTheSections(t *testing.T) {
143 106 if code != 200 || !strings.Contains(runners, "Runners and queue") || !strings.Contains(runners, "Queue") {
144 107 t.Fatalf("runners tab = %d:\n%s", code, runners)
145 108 }
146 if strings.Contains(runners, "Storage used") || strings.Contains(runners, "Page views") {
109 if strings.Contains(runners, "Storage used") {
147 110 t.Fatalf("runners tab shows overview content:\n%s", runners)
148 111 }
149 112