Phase 7 part 2: ranked by what converts

Push pages and change candidates are ordered by the sign-ups a page
would bring if clicked as usual for its position (impressions × the
clicks it misses × its sign-up rate, or the site's), and say so. What
ranks flags pages by what they convert: traffic with no sign-ups, and
pages that convert but Google hardly shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-24 07:11:16 -07:00
co-authored by Claude Opus 5.5
parent e9871082b5
commit 77f6e1e1d1
9 changed files with 325 additions and 11 deletions
+46
View File
@@ -53,6 +53,7 @@ type Pick struct {
MainShare float64 // that query's share of the page's impressions, in percent
MainPos float64 // the page's position for it
Why string
Expected float64 // more sign-ups in the period if clicked as usual for its position
}
// Ranks is job 1: what already ranks, over a period.
@@ -65,6 +66,18 @@ type Ranks struct {
Unclicked []QueryRow // shown a lot, almost never clicked
Protect []Pick
Push []Pick
// Flags mark pages by what they convert (by PathKey): FlagNoSignups or
// FlagHidden. Flagged lists them, worst first.
Flags map[string]string
Flagged []Flagged
}
// Flagged is a flagged page, with its numbers.
type Flagged struct {
Path string
Flag string
Conv PageConv
Impressions int
}
// RanksDays is the period job 1 looks at.
@@ -159,6 +172,19 @@ func WhatRanks(d *db.DB, sc Scope) (*Ranks, error) {
}
}
slices.SortStableFunc(cands, func(a, b PageRow) int { return b.Impressions - a.Impressions })
// With conversion data, the page that would bring most sign-ups first.
if sc.HasConv() {
slices.SortStableFunc(cands, func(a, b PageRow) int {
ea, eb := sc.Expected(a.Numbers, a.Page), sc.Expected(b.Numbers, b.Page)
switch {
case ea > eb:
return -1
case ea < eb:
return 1
}
return 0
})
}
for _, p := range cands {
if len(r.Push) == 3 {
break
@@ -171,8 +197,28 @@ func WhatRanks(d *db.DB, sc Scope) (*Ranks, error) {
if pick.MainQuery != "" {
pick.Why += fmt.Sprintf(" %.0f%% of its impressions come from “%s”, where it's at %.1f.", pick.MainShare, pick.MainQuery, pick.MainPos)
}
if sc.HasConv() {
pick.Expected = sc.Expected(p.Numbers, p.Page)
pick.Why += " " + expectedWhy(sc, p.Page, pick.Expected)
}
r.Push = append(r.Push, pick)
}
if sc.HasConv() {
impr := Impressions(pages)
r.Flags = sc.Flags(impr)
for p, f := range r.Flags {
r.Flagged = append(r.Flagged, Flagged{Path: p, Flag: f, Conv: sc.Conv[p], Impressions: impr[p]})
}
slices.SortFunc(r.Flagged, func(a, b Flagged) int {
if a.Flag != b.Flag {
return strings.Compare(a.Flag, b.Flag) // converts, hardly found first
}
if a.Conv.Visitors != b.Conv.Visitors {
return b.Conv.Visitors - a.Conv.Visitors
}
return strings.Compare(a.Path, b.Path)
})
}
return r, nil
}