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
+27 -4
View File
@@ -8,6 +8,7 @@ import (
"net/url"
"os"
"path/filepath"
"slices"
"strings"
"time"
@@ -218,13 +219,18 @@ type Candidate struct {
Title bool // its title should change
Desc bool // its description should change
Traffic Numbers
// Expected is how many more sign-ups the page would bring in 90 days
// if clicked as usual for its position (0 without conversion data).
Expected float64
}
// Candidates are the pages to propose changes for, best first: the pages to
// push (on page one, not clicked), then audit issues on pages with traffic,
// then audit issues on the rest. Pages with a change in the last 90 days
// are left alone.
func Candidates(d *db.DB, site, property string, now time.Time) ([]Candidate, error) {
func Candidates(d *db.DB, site, property string, conv map[string]PageConv, now time.Time) ([]Candidate, error) {
sc := NewScope(property, site)
sc.Conv = conv
recent := map[string]bool{}
rows, err := d.Query(`SELECT page FROM seo_changes WHERE site = ? AND (created_at >= ? OR status IN ('proposed', 'applying', 'pr', 'merged'))`,
site, now.AddDate(0, 0, -90).UTC().Format(time.RFC3339))
@@ -248,9 +254,9 @@ func Candidates(d *db.DB, site, property string, now time.Time) ([]Candidate, er
out = append(out, c)
}
if property != "" {
if r, err := WhatRanks(d, NewScope(property, site)); err == nil && r != nil {
if r, err := WhatRanks(d, sc); err == nil && r != nil {
for _, p := range r.Push {
add(Candidate{Page: p.Page, Why: p.Why, Title: true, Desc: true, Traffic: p.Numbers})
add(Candidate{Page: p.Page, Why: p.Why, Title: true, Desc: true, Traffic: p.Numbers, Expected: p.Expected})
}
}
}
@@ -276,11 +282,27 @@ func Candidates(d *db.DB, site, property string, now time.Time) ([]Candidate, er
c.Why = is.Title + ". " + is.Detail
if is.Traffic.Impressions > 0 {
c.Why += fmt.Sprintf(" (%s impressions, %s clicks in 90 days)", Thousands(is.Traffic.Impressions), Thousands(is.Traffic.Clicks))
if sc.HasConv() {
c.Expected = sc.Expected(is.Traffic, is.Page)
c.Why += " " + expectedWhy(sc, is.Page, c.Expected)
}
}
add(c)
}
}
}
// With conversion data, the change that would bring most sign-ups first.
if sc.HasConv() {
slices.SortStableFunc(out, func(a, b Candidate) int {
switch {
case a.Expected > b.Expected:
return -1
case a.Expected < b.Expected:
return 1
}
return 0
})
}
return out, nil
}
@@ -321,6 +343,7 @@ type Proposer struct {
AI ai.Client
Profile *profile.Profile
Fetcher *Fetcher
Conv map[string]PageConv // what the site's pages convert, to rank by it
}
var proposalSchema = map[string]any{
@@ -469,7 +492,7 @@ func (pr *Proposer) SuggestChanges(ctx context.Context, d *db.DB, site, property
if waiting >= MaxWaiting {
return 0, fmt.Errorf("%d changes already wait for your yes: decide on those first", waiting)
}
cands, err := Candidates(d, site, property, now)
cands, err := Candidates(d, site, property, pr.Conv, now)
if err != nil {
return 0, err
}