carlos / platform Public

Merge branch 'fix-console-analytics-internal-error' into main

claude agent, operated by james@keymail.dev da8a1fe13782a48ea9361f9dece2556843381650 parent 5ecf38bparent 3c33376
3 files changed, +17 −7
  • internal/console/analyticsdisplay.go +2 −2
  • internal/console/analyticspages_test.go +12 −3
  • internal/console/analyticsview.go +3 −2

CI cancelled — superseded by a newer push — run details

CI log
=== gate ===
go: downloading go1.26.10 (linux/arm64)
go version go1.26.10 linux/arm64
opentofu: arm64, tofu 1.13.9, aws 6.73.0, archive 2.8.1
  tofu: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/tofu_1.13.9_linux_arm64.tar.gz
  tofu: downloaded, digest verified
  aws: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-aws_6.73.0_linux_arm64.zip
  aws: downloaded, digest verified
  archive: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-archive_2.8.1_linux_arm64.zip
  archive: downloaded, digest verified
  installed in /tmp/carlos-opentofu-bhHUyw
.amadan/test-gate.sh
go: downloading github.com/aws/aws-sdk-go-v2 v1.44.0
go: downloading github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.68.0
go: downloading github.com/aws/smithy-go v1.28.1
go: downloading github.com/benbjohnson/litestream v0.5.14
go: downloading golang.org/x/net v0.62.0
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/aws/aws-sdk-go-v2/service/s3 v1.105.0
go: downloading github.com/superfly/ltx v0.5.1
go: downloading github.com/aws/aws-sdk-go-v2/service/costexplorer v1.67.5
go: downloading golang.org/x/crypto v0.58.0
go: downloading golang.org/x/sys v0.49.0
go: downloading github.com/aws/aws-sdk-go-v2/service/acm v1.45.0
go: downloading github.com/aws/aws-sdk-go-v2/service/ec2 v1.324.0
go: downloading github.com/aws/aws-sdk-go-v2/service/iam v1.58.2
go: downloading github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi v1.37.0
go: downloading github.com/aws/aws-sdk-go-v2/service/route53 v1.64.1
go: downloading github.com/oschwald/maxminddb-golang v1.13.1
go: downloading golang.org/x/mod v0.41.0
go: downloading github.com/pion/turn/v4 v4.1.4
go: downloading github.com/aws/aws-sdk-go-v2/service/sesv2 v1.66.6
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading github.com/klauspost/compress v1.20.2
go: downloading golang.org/x/text v0.43.0
go: downloading github.com/pion/randutil v0.1.0
go: downloading golang.org/x/sync v0.24.0
go: downloading github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.20.18
go: downloading github.com/prometheus/client_golang v1.17.0
go: downloading github.com/lmittmann/tint v1.1.3
go: downloading github.com/prometheus/client_model v0.5.0
go: downloading github.com/prometheus/common v0.45.0
go: downloading google.golang.org/protobuf v1.36.10
go: downloading github.com/prometheus/procfs v0.12.0
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash/v2 v2.3.0
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0
go: downloading github.com/klauspost/compress v1.20.2
go: downloading golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading google.golang.org/protobuf v1.36.10
go: downloading modernc.org/libc v1.74.1
go: downloading modernc.org/libc v1.74.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading modernc.org/memory v1.11.0
go: downloading modernc.org/mathutil v1.7.1
go: downloading github.com/google/uuid v1.6.0
go: downloading modernc.org/mathutil v1.7.1
go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec
go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec

amadan: job cancelled — a newer push superseded it
diff --git a/internal/console/analyticsdisplay.go b/internal/console/analyticsdisplay.go
index e4c108bb2..ffa890169 100644
--- a/internal/console/analyticsdisplay.go
+++ b/internal/console/analyticsdisplay.go
@@ -481,11 +481,11 @@ const topRows = 25
// and counts the rest (the overflow row included). The overflow row is the
// last row sortedKV gives, so a cut list never shows "Everything else" for
// a remainder it is not.
-func capRows(rows []shareRow, n int) ([]shareRow, int) {
+func capRows(rows []shareRow, n int) ([]shareRow, int64) {
if len(rows) <= n {
return rows, 0
}
- return rows[:n], len(rows) - n
+ return rows[:n], int64(len(rows) - n)
}
// pageSection is one group of the pages view: the pages under one top
diff --git a/internal/console/analyticspages_test.go b/internal/console/analyticspages_test.go
index f3b943f51..f8c7dfadf 100644
--- a/internal/console/analyticspages_test.go
+++ b/internal/console/analyticspages_test.go
@@ -77,14 +77,17 @@ func sectionNames(secs []pageSection) []string {
// The tab shows 25 pages and a link to all of them; the pages view lists
// every page by group, with a filter, and its period links keep the view.
-// Named events are gone from the tab.
+// Named events are gone from the tab. Past 25 referrers the tab counts the
+// rest (a page that once failed to render: ReferersMore was an int handed
+// to the int64 count func).
func TestAnalyticsPagesView(t *testing.T) {
fx, _ := instanceFixture(t, "code-analytics-pages")
when := seedTime()
m := analytics.NewMeter(t.TempDir(), "box1", func() time.Time { return when })
for i := 0; i < 30; i++ {
m.Observe(analytics.Obs{Acct: release.OpsAccount, App: "titogo", Host: "titogo.example.com", Method: "GET", Status: 200,
- ContentType: "text/html", Path: fmt.Sprintf("/posts/%d.html", i), UA: "Mozilla/5.0 Safari", ClientIP: fmt.Sprintf("203.0.113.%d", i), When: when})
+ ContentType: "text/html", Path: fmt.Sprintf("/posts/%d.html", i), UA: "Mozilla/5.0 Safari", ClientIP: fmt.Sprintf("203.0.113.%d", i),
+ RefererHost: fmt.Sprintf("ref%d.example.net", i), When: when})
}
for k, ds := range m.Drain() {
for _, d := range ds {
@@ -102,7 +105,13 @@ func TestAnalyticsPagesView(t *testing.T) {
c := newBrowser(t)
signUp(t, fx, c, "code-analytics-pages-browser")
- _, _, body := get(t, c, fx.u("/apps/titogo/analytics?range=7d"))
+ status, _, body := get(t, c, fx.u("/apps/titogo/analytics?range=7d"))
+ if status != 200 {
+ t.Fatalf("tab = %d: %.300s", status, body)
+ }
+ if !strings.Contains(body, "5 more referrers not shown.") {
+ t.Error("tab does not count the referrers past 25")
+ }
if n := strings.Count(body, `<span class="an-key" title="/posts/`); n != topRows {
t.Errorf("tab shows %d pages, want %d", n, topRows)
}
diff --git a/internal/console/analyticsview.go b/internal/console/analyticsview.go
index d80a55928..fda74065c 100644
--- a/internal/console/analyticsview.go
+++ b/internal/console/analyticsview.go
@@ -254,8 +254,9 @@ type analyticsWindow struct {
// side that can be opened (dayNeighbours).
Date, Prev, Next string
// PagesMore and ReferersMore are the rows past the tab's first 25,
- // shown in full by the pages view (Sections) or counted.
- PagesMore, ReferersMore int
+ // shown in full by the pages view (Sections) or counted. int64, as
+ // the count template func takes nothing else.
+ PagesMore, ReferersMore int64
PagesTotal int64 // pages counted, not the overflow row
// Browsers and Devices are page views by browser family and device
// class; Bots is bot requests by name (internal/analytics agents.go).