Skip to content

Commit

Permalink
update db queries
Browse files Browse the repository at this point in the history
Signed-off-by: MUzairS15 <[email protected]>
  • Loading branch information
MUzairS15 committed Aug 13, 2024
1 parent 11081d0 commit a091e94
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion models/meshmodel/registry/v1alpha3/relationship_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func (relationshipFilter *RelationshipFilter) Get(db *database.Handler) ([]entit
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
status := "enabled"

if relationshipFilter.Status != "" {
Expand Down
16 changes: 8 additions & 8 deletions models/meshmodel/registry/v1beta1/model_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ func (mf *ModelFilter) Get(db *database.Handler) ([]entity.Entity, int64, int, e
finder = finder.Order("display_name")
}

status := "enabled"

if mf.Status != "" {
status = mf.Status
}

finder = finder.Where("model_dbs.status = ?", status)

finder.Count(&count)

if mf.Limit != 0 {
Expand All @@ -155,14 +163,6 @@ func (mf *ModelFilter) Get(db *database.Handler) ([]entity.Entity, int64, int, e
finder = finder.Offset(mf.Offset)
}

status := "enabled"

if mf.Status != "" {
status = mf.Status
}

finder = finder.Where("model_dbs.status = ?", status)

includeComponents = mf.Components
includeRelationships = mf.Relationships

Expand Down

0 comments on commit a091e94

Please sign in to comment.