Skip to content

Commit

Permalink
Merge pull request #606 from Yashsharma1911/yash/updateMeshModelAPIFT…
Browse files Browse the repository at this point in the history
…oFetchById

Added missing condition to fetch entities by ID
  • Loading branch information
Yashsharma1911 authored Oct 13, 2024
2 parents d68b122 + 35ea71e commit f3d4b89
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions models/meshmodel/registry/v1alpha3/relationship_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ func (relationshipFilter *RelationshipFilter) Get(db *database.Handler) ([]entit
if relationshipFilter.SubType != "" {
finder = finder.Where("relationship_definition_dbs.sub_type = ?", relationshipFilter.SubType)
}
if relationshipFilter.Id != "" {
finder = finder.Where("relationship_definition_dbs.id = ?", relationshipFilter.Id)
}
if relationshipFilter.ModelName != "" {
finder = finder.Where("model_dbs.name = ?", relationshipFilter.ModelName)
}
Expand Down
3 changes: 3 additions & 0 deletions models/meshmodel/registry/v1beta1/category_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ func (cf *CategoryFilter) Get(db *database.Handler) ([]entity.Entity, int64, int
finder = finder.Where("name = ?", cf.Name)
}
}
if cf.Id != "" {
finder = finder.Where("id = ?", cf.Id)
}
if cf.OrderOn != "" {
if cf.Sort == "desc" {
finder = finder.Order(clause.OrderByColumn{Column: clause.Column{Name: cf.OrderOn}, Desc: true})
Expand Down
4 changes: 3 additions & 1 deletion models/meshmodel/registry/v1beta1/component_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ func (componentFilter *ComponentFilter) Get(db *database.Handler) ([]entity.Enti
if componentFilter.Version != "" {
finder = finder.Where("model_dbs.model->>'version' = ?", componentFilter.Version)
}

if componentFilter.Id != "" {
finder = finder.Where("component_definition_dbs.id = ?", componentFilter.Id)
}
if componentFilter.OrderOn != "" {
if componentFilter.Sort == "desc" {
finder = finder.Order(clause.OrderByColumn{Column: clause.Column{Name: componentFilter.OrderOn}, Desc: true})
Expand Down
3 changes: 3 additions & 0 deletions models/meshmodel/registry/v1beta1/model_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ func (mf *ModelFilter) Get(db *database.Handler) ([]entity.Entity, int64, int, e
} else if mf.Annotations == "false" {
finder = finder.Where("model_dbs.metadata->>'isAnnotation' = false")
}
if mf.Id != "" {
finder = finder.Where("model_dbs.id = ?", mf.Id)
}
if mf.OrderOn != "" {
if mf.Sort == "desc" {
finder = finder.Order(clause.OrderByColumn{Column: clause.Column{Name: mf.OrderOn}, Desc: true})
Expand Down
4 changes: 3 additions & 1 deletion models/meshmodel/registry/v1beta1/policy_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ func (pf *PolicyFilter) Get(db *database.Handler) ([]entity.Entity, int64, int,
if pf.ModelName != "" {
finder = finder.Where("model_dbs.name = ?", pf.ModelName)
}

if pf.Id != "" {
finder = finder.Where("policy_definition_dbs.id = ?", pf.Id)
}
var count int64
finder.Count(&count)

Expand Down

0 comments on commit f3d4b89

Please sign in to comment.