Skip to content

Commit

Permalink
refactor: Query only models with enabled status
Browse files Browse the repository at this point in the history
Signed-off-by: Nithish Karthik <[email protected]>
  • Loading branch information
humblenginr committed Aug 6, 2024
1 parent 1803ab0 commit def3f00
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions models/meshmodel/registry/v1alpha2/relationship_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ func (relationshipFilter *RelationshipFilter) Get(db *database.Handler) ([]entit
finder := db.Model(&v1alpha2.RelationshipDefinition{}).Preload("Model").Preload("Model.Category").
Joins("JOIN model_dbs ON relationship_definition_dbs.model_id = model_dbs.id").
Joins("JOIN category_dbs ON model_dbs.category_id = category_dbs.id")

// TODO(@MUzairS15): Refactor this once Status is made a first class field in RelationshipFilter
finder = finder.Where("model_dbs.status = enabled")

if relationshipFilter.Kind != "" {
if relationshipFilter.Greedy {
finder = finder.Where("relationship_definition_dbs.kind LIKE ?", "%"+relationshipFilter.Kind+"%")
Expand Down
3 changes: 3 additions & 0 deletions models/meshmodel/registry/v1beta1/component_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ func (componentFilter *ComponentFilter) Get(db *database.Handler) ([]entity.Enti
Joins("JOIN hosts ON hosts.id = model_dbs.host_id")
//

// TODO(@MUzairS15): Refactor this once Status is made a first class field in ComponentFilter
finder = finder.Where("model_dbs.status = enabled")

if componentFilter.Greedy {
if componentFilter.Name != "" && componentFilter.DisplayName != "" {
finder = finder.Where("component_definition_dbs.component->>'kind' LIKE ? OR display_name LIKE ?", "%"+componentFilter.Name+"%", componentFilter.DisplayName+"%")
Expand Down

0 comments on commit def3f00

Please sign in to comment.