fix(outages): format numeric portal dates as integers
Portal date fields arrive as numbers; fmt's %v rendered them in scientific notation, so the "current outage" filter could not parse them and kept past outages (a 'Прошлые' record leaked through). Format integer-valued attributes explicitly.
This commit is contained in:
@@ -191,14 +191,22 @@ func codeKey(v any) string {
|
||||
}
|
||||
}
|
||||
|
||||
// stringOf renders an attribute value as a string. The important case is
|
||||
// numeric dates: fmt's %v turns a float64 into scientific notation ("1.79e+12")
|
||||
// which the date parser cannot read, so integers are formatted explicitly.
|
||||
func stringOf(v any) string {
|
||||
if s, ok := v.(string); ok {
|
||||
return s
|
||||
}
|
||||
if v == nil {
|
||||
switch t := v.(type) {
|
||||
case nil:
|
||||
return ""
|
||||
case string:
|
||||
return t
|
||||
case float64:
|
||||
return strconv.FormatInt(int64(t), 10)
|
||||
case json.Number:
|
||||
return t.String()
|
||||
default:
|
||||
return fmt.Sprintf("%v", v)
|
||||
}
|
||||
return fmt.Sprintf("%v", v)
|
||||
}
|
||||
|
||||
// actionFor maps a portal system name to the canonical action code used by the
|
||||
|
||||
Reference in New Issue
Block a user