diff --git a/cla-backend-go/events/repository.go b/cla-backend-go/events/repository.go index aaecf207d..71a34ce55 100644 --- a/cla-backend-go/events/repository.go +++ b/cla-backend-go/events/repository.go @@ -48,6 +48,7 @@ const ( EventCompanySFIDEventDataLowerIndex = "event-company-sfid-event-data-lower-index" CompanyIDExternalProjectIDEventEpochTimeIndex = "company-id-external-project-id-event-epoch-time-index" CompanySFIDClaGroupIDEpochIndex = "company-sfid-cla-group-id-event-time-epoch-index" + EventProjectSFIDEventTypeIndex = "event-project-sfid-event-type-index" ) // constants @@ -254,8 +255,8 @@ func (repo *repository) SearchEvents(params *eventOps.SearchEventsParams, pageSi "pageSize": pageSize, } - if params.ProjectID == nil { - return nil, errors.New("invalid request. projectID is compulsory") + if params.ProjectID == nil && params.ProjectSFID == nil { + return nil, errors.New("invalid request. projectID|projectSFID is compulsory") } var condition expression.KeyConditionBuilder var indexName, pk, sk string @@ -269,7 +270,14 @@ func (repo *repository) SearchEvents(params *eventOps.SearchEventsParams, pageSi pk = "event_project_id" condition = addTimeExpression(condition, params) sk = "event_time_epoch" + case params.ProjectSFID != nil: + // search by projectSFID + indexName = EventProjectSFIDEventTypeIndex + condition = expression.Key("event_project_sfid").Equal(expression.Value(params.ProjectSFID)).And(expression.Key("event_type").Equal(expression.Value(params.EventType))) + pk = "event_project_sfid" + sk = "event_type" } + filter := createSearchEventFilter(pk, sk, params) if filter != nil { builder = builder.WithFilter(*filter) diff --git a/cla-backend-go/signatures/converters.go b/cla-backend-go/signatures/converters.go index b3fedb68b..5b731bb36 100644 --- a/cla-backend-go/signatures/converters.go +++ b/cla-backend-go/signatures/converters.go @@ -162,10 +162,10 @@ func (repo repository) buildProjectSignatureModels(ctx context.Context, results if loadACLDetails { userModel, userErr := repo.usersRepo.GetUserByUserName(userName, true) if userErr != nil { - log.WithFields(f).WithError(userErr).Warnf("unable to lookup user by userNmae: %s in ACL for signature: %s", userName, sigModel.SignatureID) + log.WithFields(f).WithError(userErr).Warnf("unable to lookup user by username: %s in ACL for signature: %s", userName, sigModel.SignatureID) } else { if userModel == nil { - log.WithFields(f).Warnf("unable to lookup user by userNmae: %s in ACL for signature: %s", userName, sigModel.SignatureID) + log.WithFields(f).Warnf("unable to lookup user by username: %s in ACL for signature: %s", userName, sigModel.SignatureID) } else { signatureACL = append(signatureACL, *userModel) } diff --git a/cla-backend-go/swagger/cla.v1.yaml b/cla-backend-go/swagger/cla.v1.yaml index 93579b54b..8343a1a64 100644 --- a/cla-backend-go/swagger/cla.v1.yaml +++ b/cla-backend-go/swagger/cla.v1.yaml @@ -2300,6 +2300,7 @@ paths: - $ref: '#/parameters/userID' - $ref: '#/parameters/companyID' - $ref: '#/parameters/projectID' + - $ref: '#/parameters/projectSFID' - $ref: '#/parameters/before' - $ref: '#/parameters/after' - $ref: '#/parameters/userName' @@ -2551,6 +2552,11 @@ parameters: description: unique id of the project in: query type: string + projectSFID: + name: projectSFID + description: unique id of the SF project + in: query + type: string companyID: name: company_id description: unique id of the company diff --git a/cla-backend-go/v2/signatures/converters.go b/cla-backend-go/v2/signatures/converters.go index 44191e60a..767d897fe 100644 --- a/cla-backend-go/v2/signatures/converters.go +++ b/cla-backend-go/v2/signatures/converters.go @@ -9,6 +9,7 @@ import ( "sync" "time" + v1Events "github.com/communitybridge/easycla/cla-backend-go/events" v1Models "github.com/communitybridge/easycla/cla-backend-go/gen/v1/models" "github.com/communitybridge/easycla/cla-backend-go/gen/v1/restapi/operations/events" "github.com/communitybridge/easycla/cla-backend-go/gen/v2/models" @@ -90,10 +91,12 @@ func (s *Service) TransformSignatureToCorporateSignature(signature *models.Signa searchTerm := fmt.Sprintf("%s was added to the approval list", item) pageSize := int64(10000) + eventType := v1Events.ClaApprovalListUpdated result, eventErr := s.eventService.SearchEvents(&events.SearchEventsParams{ - SearchTerm: &searchTerm, - ProjectID: &projectSFID, - PageSize: &pageSize, + SearchTerm: &searchTerm, + ProjectSFID: &projectSFID, + EventType: &eventType, + PageSize: &pageSize, }) if eventErr != nil { errMutex.Lock()