Skip to content

Commit

Permalink
Merge pull request #415 from MUzairS15/MUzairS15/meshmodel
Browse files Browse the repository at this point in the history
[Meshmodel] Add `ReturnAnnotaion` property in `Component Filter`
  • Loading branch information
MUzairS15 authored Nov 24, 2023
2 parents d0d5bb6 + d19f681 commit e6f80c5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions models/meshmodel/core/v1alpha1/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ func GetMeshModelComponents(db *database.Handler, f ComponentFilter) (c []Compon
Select("component_definition_dbs.*, model_dbs.*,category_dbs.*").
Joins("JOIN model_dbs ON component_definition_dbs.model_id = model_dbs.id").
Joins("JOIN category_dbs ON model_dbs.category_id = category_dbs.id") //


if f.Greedy {
if f.Name != "" && f.DisplayName != "" {
finder = finder.Where("component_definition_dbs.kind LIKE ? OR display_name LIKE ?", "%"+f.Name+"%", f.DisplayName+"%")
Expand All @@ -126,6 +128,11 @@ func GetMeshModelComponents(db *database.Handler, f ComponentFilter) (c []Compon
if f.ModelName != "" && f.ModelName != "all" {
finder = finder.Where("model_dbs.name = ?", f.ModelName)
}

if f.ReturnAnnotations {
finder = finder.Where("component_definition_dbs.metadata->>'isAnnotation' = true")
}

if f.APIVersion != "" {
finder = finder.Where("component_definition_dbs.api_version = ?", f.APIVersion)
}
Expand Down Expand Up @@ -179,6 +186,7 @@ type ComponentFilter struct {
OrderOn string
Limit int //If 0 or unspecified then all records are returned and limit is not used
Offset int
ReturnAnnotations bool
}

// Create the filter from map[string]interface{}
Expand Down

0 comments on commit e6f80c5

Please sign in to comment.