Skip to content

Commit

Permalink
Merge pull request #2146 from semaphoreui/bolt_integrations_query_opt…
Browse files Browse the repository at this point in the history
…imization

feat(bolt): optimize query
  • Loading branch information
fiftin committed Jun 30, 2024
2 parents 335ee40 + c24bcf1 commit aca9055
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions db/bolt/integrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,11 @@ func (d *BoltDb) CreateIntegrationExtractValue(projectId int, value db.Integrati

func (d *BoltDb) GetIntegrationExtractValues(projectID int, params db.RetrieveQueryParams, integrationID int) (values []db.IntegrationExtractValue, err error) {
values = make([]db.IntegrationExtractValue, 0)
var allValues []db.IntegrationExtractValue

err = d.getObjects(projectID, db.IntegrationExtractValueProps, params, nil, &allValues)

if err != nil {
return
}

for _, v := range allValues {
if v.IntegrationID == integrationID {
values = append(values, v)
}
}
err = d.getObjects(projectID, db.IntegrationExtractValueProps, params, func(i interface{}) bool {
v := i.(db.IntegrationExtractValue)
return v.IntegrationID == integrationID
}, &values)

return
}
Expand Down Expand Up @@ -120,19 +112,11 @@ func (d *BoltDb) CreateIntegrationMatcher(projectID int, matcher db.IntegrationM

func (d *BoltDb) GetIntegrationMatchers(projectID int, params db.RetrieveQueryParams, integrationID int) (matchers []db.IntegrationMatcher, err error) {
matchers = make([]db.IntegrationMatcher, 0)
var allMatchers []db.IntegrationMatcher

err = d.getObjects(projectID, db.IntegrationMatcherProps, db.RetrieveQueryParams{}, nil, &allMatchers)

if err != nil {
return
}

for _, v := range allMatchers {
if v.IntegrationID == integrationID {
matchers = append(matchers, v)
}
}
err = d.getObjects(projectID, db.IntegrationMatcherProps, db.RetrieveQueryParams{}, func(i interface{}) bool {
v := i.(db.IntegrationMatcher)
return v.IntegrationID == integrationID
}, &matchers)

return
}
Expand Down

0 comments on commit aca9055

Please sign in to comment.