Skip to content

Commit

Permalink
[#3750] Bug/Approval List Child Projects
Browse files Browse the repository at this point in the history
- Added project_sfid on events fetching datetime values for approval list items

Signed-off-by: Harold Wanyama <[email protected]>
  • Loading branch information
nickmango committed Feb 23, 2024
1 parent 2d89f9c commit 63d7cdf
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
12 changes: 10 additions & 2 deletions cla-backend-go/events/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cla-backend-go/signatures/converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 6 additions & 0 deletions cla-backend-go/swagger/cla.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions cla-backend-go/v2/signatures/converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 63d7cdf

Please sign in to comment.