fix(inventory-go): backfill-od clears stale od_rating for non-matching weapons
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
2395bd6267
commit
9f908aed9e
1 changed files with 10 additions and 4 deletions
|
|
@ -259,10 +259,10 @@ func (s *Server) handleBackfillOD(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
type upd struct {
|
type upd struct {
|
||||||
id int
|
id int
|
||||||
od float64
|
od *float64 // nil → clear stale OD (weapon no longer matches any rule)
|
||||||
}
|
}
|
||||||
var updates []upd
|
var updates []upd
|
||||||
scanned := 0
|
scanned, rated := 0, 0
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var id int
|
var id int
|
||||||
var oj map[string]any
|
var oj map[string]any
|
||||||
|
|
@ -273,7 +273,13 @@ func (s *Server) handleBackfillOD(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
scanned++
|
scanned++
|
||||||
if od, ok := computeOD(oj); ok {
|
if od, ok := computeOD(oj); ok {
|
||||||
updates = append(updates, upd{id, od})
|
v := od
|
||||||
|
updates = append(updates, upd{id, &v})
|
||||||
|
rated++
|
||||||
|
} else {
|
||||||
|
// No matching rule → ensure od_rating is NULL (clears any stale value
|
||||||
|
// from a prior formula so the column never keeps a wrong number).
|
||||||
|
updates = append(updates, upd{id, nil})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rows.Close()
|
rows.Close()
|
||||||
|
|
@ -285,7 +291,7 @@ func (s *Server) handleBackfillOD(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
updated++
|
updated++
|
||||||
}
|
}
|
||||||
writeJSON(w, http.StatusOK, map[string]any{"scanned": scanned, "updated": updated})
|
writeJSON(w, http.StatusOK, map[string]any{"scanned": scanned, "rated": rated, "updated": updated})
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseNaiveTime(s string) time.Time {
|
func parseNaiveTime(s string) time.Time {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue