Metrics: every cohort over every month, percentages and dollars aligned
Both cohort tables (MRR retention on Metrics, revenue per customer on CLV) and their CSVs now show every cohort, each followed to the latest month, instead of the last 12 or 18 for 12 or 24 months. Each MRR cohort is now two rows, the share of starting MRR and the dollars under it, so the numbers line up across months; the month, customers and starting MRR span both rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -54,8 +54,9 @@ func (s *Server) renderMetrics(w http.ResponseWriter, r *http.Request, errMsg st
|
||||
"Now": model.Last(),
|
||||
"Recent": model.Recent(13),
|
||||
"Bars": bars(model, 24),
|
||||
"Cohorts": model.Cohorts(12, 12),
|
||||
"Span": make([]int, 13),
|
||||
// Every cohort, each followed to the latest month.
|
||||
"Cohorts": model.Cohorts(len(model.Months), max(len(model.Months)-1, 0)),
|
||||
"Span": make([]int, len(model.Months)),
|
||||
}})
|
||||
}
|
||||
|
||||
@@ -429,13 +430,14 @@ func (s *Server) metricsCLV(w http.ResponseWriter, r *http.Request) {
|
||||
s.serverError(w, err)
|
||||
return
|
||||
}
|
||||
cohorts, err := metrics.RevenueByCohort(s.DB, model, 18, 12, now)
|
||||
span := max(len(model.Months)-1, 0) // every cohort, to the latest month
|
||||
cohorts, err := metrics.RevenueByCohort(s.DB, model, len(model.Months), span, now)
|
||||
if err != nil {
|
||||
s.serverError(w, err)
|
||||
return
|
||||
}
|
||||
s.render(w, r, "metrics-clv", page{Title: "CLV and cohorts", Nav: "metrics/clv", Data: map[string]any{
|
||||
"CLV": clv, "Cohorts": cohorts, "Span": make([]int, 13), "Profit": r.URL.Query().Get("view") == "profit",
|
||||
"CLV": clv, "Cohorts": cohorts, "Span": make([]int, span+1), "Profit": r.URL.Query().Get("view") == "profit",
|
||||
"Currency": model.Currency,
|
||||
}})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user