Skip to content

Commit

Permalink
removed redundant index for customerGUID and added tests for uiStatus…
Browse files Browse the repository at this point in the history
….processingStatis

Signed-off-by: radoslawd <[email protected]>
  • Loading branch information
radoslawdob committed Aug 2, 2023
1 parent 78d9c56 commit 67d99d2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
8 changes: 1 addition & 7 deletions db/mongo/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ var collectionIndexes = map[string][]mongo.IndexModel{
},
Options: options.Index().SetBackground(true),
},
{
Keys: bson.D{
{Key: "customerGUID", Value: 1},
},
Options: options.Index().SetBackground(true),
},
{
Keys: bson.D{
{Key: "latestReportGUID", Value: 1},
Expand All @@ -92,7 +86,7 @@ var collectionIndexes = map[string][]mongo.IndexModel{
},
{
Keys: bson.D{
{Key: "uiStatus.processing", Value: 1},
{Key: "uiStatus.processingStatus", Value: 1},
},
Options: options.Index().SetBackground(true),
},
Expand Down
1 change: 0 additions & 1 deletion routes/v1/attack_chains/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ func AddRoutes(g *gin.Engine) {
WithValidatePostUniqueName(false).
WithValidatePostMandatoryName(true).
WithPostValidators(validateAttackChainId).
WithUniqueShortName(handlers.NameValueGetter[*types.AttackChain]).
Get()...)
}
25 changes: 25 additions & 0 deletions service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,31 @@ func (suite *MainTestSuite) TestAttackChainsConfigs() {
},
},
},
//field or match
{
testName: "uiStatus.processingStatus = processing query match test",
expectedIndexes: []int{2},
listRequest: armotypes.V2ListRequest{
OrderBy: "name:asc",
InnerFilters: []map[string]string{
{
"uiStatus.processingStatus": "processing",
},
},
},
},
{
testName: "uiStatus.processingStatus = done query match test",
expectedIndexes: []int{0, 1},
listRequest: armotypes.V2ListRequest{
OrderBy: "name:asc",
InnerFilters: []map[string]string{
{
"uiStatus.processingStatus": "done",
},
},
},
},
}

testPostV2ListRequest(suite, consts.AttackChainsPath, attackChainConfigs, projectedDocs, searchQueries, commonCmpFilter, ignoreTime)
Expand Down
2 changes: 1 addition & 1 deletion test_data/attack-chain-configs.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"uiStatus": {
"firstSeen": "2022-04-28T14:59:44.147901",
"wasViewedMainScreen": "2022-04-28T14:59:44.147901",
"processingStatus": "done"
"processingStatus": "processing"
}
}
]

0 comments on commit 67d99d2

Please sign in to comment.