Inventory: competitor prices, as checked
Each Inventory entry can hold its plans' prices: the plan, the price, what it's per, when it was checked and where. Comparison and alternative pages, and new sections, state a competitor's price only as entered, with the month it was checked; a missing one is left out and listed as a to-do. A price checked more than six months ago is flagged on the entry and adds a to-do to every page that names the competitor. Prices go out and come back with the Inventory's YAML. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -40,10 +41,14 @@ type entryData struct {
|
||||
Suggestions []inventory.Suggestion
|
||||
CanCheck bool // Reddit could be asked about the suggestions
|
||||
Drafted bool
|
||||
Today string // for new price rows
|
||||
Blank []int // empty price rows to show
|
||||
Stale []inventory.Price // prices due for another look
|
||||
}
|
||||
|
||||
func (s *Server) entryForm(e *inventory.Entry) entryData {
|
||||
d := entryData{E: e, Relationships: inventory.Relationships, NoAI: !s.aiReady()}
|
||||
d := entryData{E: e, Relationships: inventory.Relationships, NoAI: !s.aiReady(),
|
||||
Today: time.Now().Format("2006-01-02"), Blank: []int{0, 1}, Stale: e.StalePrices(time.Now())}
|
||||
if len(e.Websites) > 0 {
|
||||
d.DraftURL = e.Websites[0]
|
||||
}
|
||||
@@ -111,9 +116,27 @@ func entryFromForm(r *http.Request) *inventory.Entry {
|
||||
Keywords: profile.Lines(f.Get("keywords")),
|
||||
TalkingPoints: f.Get("talking_points"),
|
||||
MentionPolicy: f.Get("mention_policy"),
|
||||
Prices: pricesFromForm(f),
|
||||
}
|
||||
}
|
||||
|
||||
// pricesFromForm reads the price rows (price_plan, price_amount… in step).
|
||||
func pricesFromForm(f url.Values) []inventory.Price {
|
||||
var out []inventory.Price
|
||||
amounts := f["price_amount"]
|
||||
at := func(name string, i int) string {
|
||||
if v := f[name]; i < len(v) {
|
||||
return v[i]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
for i := range amounts {
|
||||
out = append(out, inventory.Price{Plan: at("price_plan", i), Amount: amounts[i], Per: at("price_per", i),
|
||||
Checked: at("price_checked", i), Source: at("price_source", i)})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// inventoryFill fills the form's empty boxes from the entry's website, with
|
||||
// the AI, and shows the form again, unsaved.
|
||||
func (s *Server) inventoryFill(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user