MCPcopy Create free account
hub / github.com/PostHog/duckgres / jsonFieldOrder

Function jsonFieldOrder

controlplane/admin/models_api.go:218–242  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

216}
217
218// modelSummary is a sidebar entry: identity plus a live row count.
219type modelSummary struct {
220 Key string `json:"key"`
221 Label string `json:"label"`
222 Group string `json:"group"`
223 Count int64 `json:"count"`
224}
225
226func (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 {

Callers 2

getModelMethod · 0.85

Calls 1

GetMethod · 0.45

Tested by 1