Skip to content

Commit

Permalink
Merge pull request #537 from humblenginr/redundant_func
Browse files Browse the repository at this point in the history
Remove Redundant Function - `registerModels`
  • Loading branch information
humblenginr authored Jul 31, 2024
2 parents 0c85e8c + d5bdeed commit 1803ab0
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions models/meshmodel/core/v1beta1/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ func (m *Model) Create(db *database.Handler, hostID uuid.UUID) (uuid.UUID, error
if err != nil {
return uuid.UUID{}, err
}
// register model inside registries table
err = registerModel(db, hostID, modelID)
if err != nil {
return uuid.UUID{}, err
}
return m.ID, nil
}
return model.ID, nil
Expand Down Expand Up @@ -140,20 +135,3 @@ func (c Model) WriteModelDefinition(modelDefPath string, outputType string) erro
return nil
}

// Registers models into registries table.
func registerModel(db *database.Handler, regID, modelID uuid.UUID) error {
var count int64
err := db.Table("registries").Where("registrant_id = ?", regID).Where("type = ?", "model").Where("entity = ?", modelID).Count(&count).Error

if err != nil && err != gorm.ErrRecordNotFound {
return err
}

if count == 0 {
err = db.Exec("INSERT INTO registries (registrant_id, entity, type) VALUES (?,?,?)", regID, modelID, "model").Error
if err != nil {
return err
}
}
return nil
}

0 comments on commit 1803ab0

Please sign in to comment.