Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this runs through the background and removes any experiments that are… #302

Merged
merged 7 commits into from
Sep 7, 2018

Conversation

thomaszurkan-optimizely
Copy link
Contributor

… not in a fresh datafile

Copy link
Contributor

@msohailhussain msohailhussain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR looks good to me.
Can we add one unit test.
Load one datafile, set userprofile, then load another datafile which doesn't have the same experiment mapped in userprofile. and call cleanup service and check what result is returned.

Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as @msohailhussain , please add unit tests for these methods.

Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly ok, just need a few more tests


- (void)removeInvalidExperimentsForAllUsers:(NSArray<NSString *> *)validExperimentIds {

NSMutableDictionary*userProflieService = [[self.dataStore getUserDataForType:OPTLYDataStoreDataTypeUserProfileService] mutableCopy];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: typo in userProflieService. Also need a space before it

- (void)cleanUserProfileService:(NSArray<OPTLYExperiment> *)experiments {
if (experiments == nil) return;

if (_userProfileService != nil && [(NSObject *)_userProfileService respondsToSelector:@selector(removeInvalidExperimentsForAllUsers:)]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems dangerous, as in, should we wrap it in a try/catch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

respondsToSelector is a test. I can't think of a possible reason an exception could be thrown here.

@@ -52,4 +52,8 @@ __attribute((deprecated("Use OPTLYManager initWithBuilder method instead.")));
**/
- (void)removeAllUserExperimentRecords;

/**
* Cleanup and remove experiments that are not in the valid experiment list passed in.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Clean up...

@@ -67,6 +69,29 @@ @interface OPTLYManagerBase()

@implementation OPTLYManagerBase

- (void)cleanUserProfileService:(NSArray<OPTLYExperiment> *)experiments {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add some unit tests for this method, particularly around failure scenarios

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikeng13 done

Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just a few small nits


[manager cleanUserProfileService:client.optimizely.config.experiments];


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: exceess new lines?

@@ -53,7 +53,11 @@ __attribute((deprecated("Use OPTLYManager initWithBuilder method instead.")));
- (void)removeAllUserExperimentRecords;

/**
* Cleanup and remove experiments that are not in the valid experiment list passed in.
* Clean up and remove experiments that are not in the valid experiment list passed in.
* This is called when initialzied from a remote datafile to ensure that the UserProfileService
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: typo --> initialized

@thomaszurkan-optimizely thomaszurkan-optimizely merged commit 12bf48a into master Sep 7, 2018
@thomaszurkan-optimizely thomaszurkan-optimizely deleted the cleanup/userprofileservice branch September 7, 2018 20:05
AbdurRafay pushed a commit that referenced this pull request Sep 10, 2018
* master:
  this runs through the background and removes any experiments that are… (#302)
  Updating libraries based on SourceClear recommendation (#304)
  add credits for third party libraries (#299)

# Conflicts:
#	OptimizelySDKUniversal/generated-frameworks/Release-iOS-universal-SDK/OptimizelySDKiOS.framework.zip
#	OptimizelySDKUniversal/generated-frameworks/Release-iOS-universal-SDK/OptimizelySDKiOS.framework/OptimizelySDKiOS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants