Skip to content

Commit

Permalink
return host metdata with models
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav Singh <pranavsingh02@hotmail.com>
  • Loading branch information
theBeginner86 committed Sep 28, 2023
1 parent a85f6ae commit 9160e59
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions models/meshmodel/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func registerModel(db *database.Handler, regID, modelID uuid.UUID) error {
entity := Registry{
RegistrantID: regID,
Entity: modelID,
Type: types.ModelDefinition,
Type: types.Model,
}

byt, err := json.Marshal(entity)
Expand Down Expand Up @@ -186,7 +186,6 @@ func (rm *RegistryManager) RegisterEntity(h Host, en Entity) error {
if err != nil {
return err
}


entry := Registry{
ID: uuid.New(),
Expand Down Expand Up @@ -251,7 +250,7 @@ func (rm *RegistryManager) GetModels(db *database.Handler, f types.Filter) ([]v1
var modelWithCategoriess []modelWithCategories
finder := db.Model(&v1alpha1.ModelDB{}).
Select("model_dbs.*, category_dbs.*").
Joins("JOIN category_dbs ON model_dbs.category_id = category_dbs.id") //
Joins("JOIN category_dbs ON model_dbs.category_id = category_dbs.id")

// total count before pagination
var count int64
Expand Down Expand Up @@ -304,7 +303,13 @@ func (rm *RegistryManager) GetModels(db *database.Handler, f types.Filter) ([]v1
}

for _, modelDB := range modelWithCategoriess {
m = append(m, modelDB.ModelDB.GetModel(modelDB.GetCategory(db)))
model := modelDB.ModelDB.GetModel(modelDB.GetCategory(db))
// mod := Entity(model)
host := rm.GetRegistrant(model)
model.HostID = host.ID
model.HostName = host.Hostname
model.DisplayHostName = host.Hostname
m = append(m, model)
}
return m, count, countUniqueModels(modelWithCategoriess)
}
Expand Down

0 comments on commit 9160e59

Please sign in to comment.