@@ -50,6 +50,7 @@ const (
5050type ProjectRepository interface { //nolint
5151 CreateCLAGroup (ctx context.Context , claGroupModel * models.ClaGroup ) (* models.ClaGroup , error )
5252 GetCLAGroupByID (ctx context.Context , claGroupID string , loadRepoDetails bool ) (* models.ClaGroup , error )
53+ GetCLAGroupByIDCompat (ctx context.Context , claGroupID string , loadRepoDetails bool ) (* models.ClaGroup , error )
5354 GetCLAGroupsByExternalID (ctx context.Context , params * project.GetProjectsByExternalIDParams , loadRepoDetails bool ) (* models.ClaGroups , error )
5455 GetCLAGroupByName (ctx context.Context , claGroupName string ) (* models.ClaGroup , error )
5556 GetExternalCLAGroup (ctx context.Context , claGroupExternalID string ) (* models.ClaGroup , error )
@@ -149,7 +150,7 @@ func (repo *repo) CreateCLAGroup(ctx context.Context, claGroupModel *models.ClaG
149150 return claGroupModel , nil
150151}
151152
152- func (repo * repo ) getCLAGroupByID (ctx context.Context , claGroupID string , loadCLAGroupDetails bool ) (* models.ClaGroup , error ) {
153+ func (repo * repo ) getCLAGroupByID (ctx context.Context , claGroupID string , loadCLAGroupDetails bool , claEnabledDefaultIsTrue bool ) (* models.ClaGroup , error ) {
153154 f := logrus.Fields {
154155 "functionName" : "project.repository.getCLAGroupByID" ,
155156 utils .XREQUESTID : ctx .Value (utils .XREQUESTID ),
@@ -188,19 +189,36 @@ func (repo *repo) getCLAGroupByID(ctx context.Context, claGroupID string, loadCL
188189 return nil , & utils.CLAGroupNotFound {CLAGroupID : claGroupID }
189190 }
190191 var dbModel models2.DBProjectModel
191- err = dynamodbattribute .UnmarshalMap (results .Items [0 ], & dbModel )
192+ rawItem := results .Items [0 ]
193+ err = dynamodbattribute .UnmarshalMap (rawItem , & dbModel )
192194 if err != nil {
193195 log .WithFields (f ).Warnf ("error unmarshalling db cla group model, error: %+v" , err )
194196 return nil , err
195197 }
198+ if claEnabledDefaultIsTrue {
199+ // If missing, assume true like Pynamo default=True
200+ if _ , ok := rawItem ["project_icla_enabled" ]; ! ok {
201+ dbModel .ProjectIclaEnabled = true
202+ }
203+ if _ , ok := rawItem ["project_ccla_enabled" ]; ! ok {
204+ dbModel .ProjectCclaEnabled = true
205+ }
206+ }
196207
197208 // Convert the database model to an API response model
198209 return repo .buildCLAGroupModel (ctx , dbModel , loadCLAGroupDetails ), nil
199210}
200211
201212// GetCLAGroupByID returns the cla group model associated for the specified claGroupID
202213func (repo * repo ) GetCLAGroupByID (ctx context.Context , claGroupID string , loadRepoDetails bool ) (* models.ClaGroup , error ) {
203- return repo .getCLAGroupByID (ctx , claGroupID , loadRepoDetails )
214+ return repo .getCLAGroupByID (ctx , claGroupID , loadRepoDetails , false )
215+ }
216+
217+ // GetCLAGroupByIDCompat returns the cla group model associated for the specified claGroupID
218+ func (repo * repo ) GetCLAGroupByIDCompat (ctx context.Context , claGroupID string , loadRepoDetails bool ) (* models.ClaGroup , error ) {
219+ // Uses compatible mode (with python v2): claEnabledDefaultIsTrue - means if project_ccla_enabled or project_icla_enabled
220+ // aren't set on dynamoDB item - they will default to true as in Py V2 API
221+ return repo .getCLAGroupByID (ctx , claGroupID , loadRepoDetails , true )
204222}
205223
206224// GetCLAGroupsByExternalID queries the database and returns a list of the cla groups
@@ -383,7 +401,7 @@ func (repo *repo) GetClaGroupByProjectSFID(ctx context.Context, projectSFID stri
383401
384402 log .WithFields (f ).Debugf ("found CLA Group ID: %s for project SFID: %s" , claGroupProject .ClaGroupID , projectSFID )
385403
386- return repo .getCLAGroupByID (ctx , claGroupProject .ClaGroupID , loadRepoDetails )
404+ return repo .getCLAGroupByID (ctx , claGroupProject .ClaGroupID , loadRepoDetails , false )
387405}
388406
389407// GetCLAGroupByName returns the project model associated for the specified project name
0 commit comments