Skip to content

Commit

Permalink
feat: disabled plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
darkweaver87 authored Jul 25, 2022
1 parent 7b59c40 commit 3622845
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Plugin struct {
Stars int `json:"stars,omitempty" bson:"stars"`
Snippet map[string]interface{} `json:"snippet,omitempty" bson:"snippet"`
CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
Disabled bool `json:"disabled,omitempty" bson:"disabled"`
}

// PluginHash The plugin hash tuple..
Expand Down
2 changes: 1 addition & 1 deletion pkg/db/mongodb/plugindb.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (m *MongoDB) List(ctx context.Context, page db.Pagination) ([]db.Plugin, st
ctx, span := m.tracer.Start(ctx, "db_create")
defer span.End()

criteria := bson.D{}
criteria := bson.D{{Key: "disabled", Value: bson.D{{Key: "$in", Value: bson.A{false, nil}}}}}

if len(page.Start) > 0 {
// page.Start represents a MongoDB ID and we can't use the $gt operator on a string, it must be done
Expand Down
6 changes: 6 additions & 0 deletions pkg/db/mongodb/plugindb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ func TestMongoDB_List(t *testing.T) {
Plugin: db.Plugin{ID: "456", Stars: 8},
},
},
{
key: "disabled",
plugin: pluginDocument{
Plugin: db.Plugin{ID: "789", Stars: 8, Disabled: true},
},
},
})

// Make sure plugins are listed ordered by stars and respect pagination constraints
Expand Down

0 comments on commit 3622845

Please sign in to comment.