jsonFieldOrder returns the ordered top-level JSON keys for a struct type, skipping fields tagged json:"-". Embedded warehouse sub-structs are named fields (json:"s3", …) so they surface as a single nested-object column, which is what the detail view renders. This gives the table stable column header
(t reflect.Type)
| 216 | } |
| 217 | |
| 218 | // modelSummary is a sidebar entry: identity plus a live row count. |
| 219 | type modelSummary struct { |
| 220 | Key string `json:"key"` |
| 221 | Label string `json:"label"` |
| 222 | Group string `json:"group"` |
| 223 | Count int64 `json:"count"` |
| 224 | } |
| 225 | |
| 226 | func (h *modelsHandler) listModels(c *gin.Context) { |
| 227 | db := h.store.DB() |
| 228 | descriptors := modelDescriptors() |
| 229 | out := make([]modelSummary, 0, len(descriptors)) |
| 230 | for _, d := range descriptors { |
| 231 | var count int64 |
| 232 | // A count failure on one table must not blank the whole sidebar; report |
| 233 | // -1 so the UI can show "?" while the rest of the list still renders. |
| 234 | if err := db.Table(h.qualifiedTable(d)).Count(&count).Error; err != nil { |
| 235 | count = -1 |
| 236 | } |
| 237 | out = append(out, modelSummary{ |
| 238 | Key: d.Key, |
| 239 | Label: d.Label, |
| 240 | Group: string(d.Group), |
| 241 | Count: count, |
| 242 | }) |
| 243 | } |
| 244 | autoTables, err := h.discoverTables() |
| 245 | if err == nil { |