Skip to content

Commit

Permalink
chore: Add indexes for collections
Browse files Browse the repository at this point in the history
This commit adds indexes for the following collections:
- `consts.UsersNotificationsCacheCollection`
- `consts.ClustersCollection`
- `consts.TokensCollection`
- `consts.VulnerabilityExceptionPolicyCollection`

The indexes are defined in the `db/mongo/index.go` file.

Signed-off-by: Bezalel Brandwine <[email protected]>
  • Loading branch information
Bezalel Brandwine committed Jul 28, 2024
1 parent 4c4c2a6 commit 3673d0c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions db/mongo/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ var collectionIndexes = map[string][]mongo.IndexModel{
{Key: "guid", Value: 1},
},
},
{
Keys: bson.D{
{Key: "activeSubscription.licenseType", Value: 1},
{Key: "activeSubscription.subscriptionStatus", Value: 1},
{Key: "subscription_date", Value: 1},
},
},
},
consts.UsersNotificationsCacheCollection: {
{
Expand Down Expand Up @@ -322,6 +329,34 @@ var collectionIndexes = map[string][]mongo.IndexModel{
},
},
},
consts.ClustersCollection: {
{
Keys: bson.D{
{Key: "_id", Value: 1},
{Key: "customers", Value: 1},
},
},
},
// We are paying the proce of not handling this index from config service but as a module
consts.TokensCollection: {
{
Keys: bson.D{
{Key: "customerGuid", Value: 1},
{Key: "value", Value: 1},
{Key: "type", Value: 1},
},
},
},
consts.VulnerabilityExceptionPolicyCollection: {
{
Keys: bson.D{
{Key: "attributes.namespaceOnly", Value: 1},
{Key: "designators.attributes.cluster", Value: 1},
{Key: "designators.attributes.namespace", Value: 1},
{Key: "customers", Value: 1},
},
},
},
}

// defaultIndex is the default index for all collections unless overridden in collectionIndexes
Expand Down
1 change: 1 addition & 0 deletions utils/consts/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const (
RuntimeIncidentCollection = "v1_runtime_incidents"
RuntimeIncidentPolicyCollection = "v1_runtime_incident_policies"
IntegrationReferenceCollection = "v1_integration_references"
TokensCollection = "tokens"

//Common document fields
IdField = "_id"
Expand Down

0 comments on commit 3673d0c

Please sign in to comment.