Skip to content

Commit

Permalink
Remove cc-skip-fixtures-after-submit code
Browse files Browse the repository at this point in the history
This feature is no longer used
  • Loading branch information
MartinRiese committed Jan 13, 2025
1 parent 2f767f4 commit 2f859f2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,7 @@ private SubmitResponseBean performSync(FormSubmissionContext context) throws Syn
//Need to do before end of form nav triggers, since the new data might change the
//validity of the form

boolean skipFixtures = storageFactory.getPropertyManager().skipFixturesAfterSubmit();
restoreFactory.performTimedSync(true, skipFixtures, false);
restoreFactory.performTimedSync(true, false);
}
return context.success();
}
Expand Down
33 changes: 15 additions & 18 deletions src/main/java/org/commcare/formplayer/services/RestoreFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ public void configure(AuthenticatedRequestBean authenticatedRequestBean, HqAuth
public UserSqlSandbox performTimedSync() throws SyncRestoreException {
return performTimedSync(true, false, false);
}
public UserSqlSandbox performTimedSync(boolean shouldPurge, boolean skipFixtures, boolean isResponseTo412)
public UserSqlSandbox performTimedSync(boolean shouldPurge, boolean isResponseTo412)
throws SyncRestoreException {
return performTimedSync(shouldPurge, skipFixtures, isResponseTo412, new HashMap<>());
return performTimedSync(shouldPurge, isResponseTo412, new HashMap<>());
}

public UserSqlSandbox performTimedSync(boolean shouldPurge, boolean skipFixtures, boolean isResponseTo412, Map<String, String> extraTags)
public UserSqlSandbox performTimedSync(boolean shouldPurge, boolean isResponseTo412, Map<String, String> extraTags)
throws SyncRestoreException {
// create extras to send to category timing helper
extraTags.put(Constants.DOMAIN_TAG, domain);
Expand All @@ -217,10 +217,10 @@ public UserSqlSandbox performTimedSync(boolean shouldPurge, boolean skipFixtures
}
UserSqlSandbox sandbox;
try {
sandbox = restoreUser(skipFixtures);
sandbox = restoreUser();
} catch (HttpClientErrorException e) {
if (e.getStatusCode().value() == 412) {
return handle412Sync(shouldPurge, skipFixtures);
return handle412Sync(shouldPurge);
}
throw e;
}
Expand All @@ -240,7 +240,7 @@ public UserSqlSandbox performTimedSync(boolean shouldPurge, boolean skipFixtures
FormplayerSentry.captureException(e, SentryLevel.WARNING);
// if we have not already, do a fresh sync to try and resolve state
if (!isResponseTo412) {
handle412Sync(shouldPurge, skipFixtures);
handle412Sync(shouldPurge);
} else {
// there are cycles even after a fresh sync
throw new SyncRestoreException(e);
Expand All @@ -257,12 +257,12 @@ public UserSqlSandbox performTimedSync(boolean shouldPurge, boolean skipFixtures
return sandbox;
}

private UserSqlSandbox handle412Sync(boolean shouldPurge, boolean skipFixtures) throws SyncRestoreException {
private UserSqlSandbox handle412Sync(boolean shouldPurge) throws SyncRestoreException {
getSQLiteDB().deleteDatabaseFile();
// this line has the effect of clearing the sync token
// from the restore URL that's used
sqLiteDB = new UserDB(domain, scrubbedUsername, asUsername);
return performTimedSync(shouldPurge, skipFixtures, true);
return performTimedSync(shouldPurge, true);
}

// This function will attempt to get the user DBs without syncing if they exist, sync if not
Expand All @@ -278,7 +278,7 @@ public UserSqlSandbox getSandbox() throws SyncRestoreException {
}

@Trace
private UserSqlSandbox restoreUser(boolean skipFixtures) throws SyncRestoreException {
private UserSqlSandbox restoreUser() throws SyncRestoreException {
PrototypeFactory.setStaticHasher(new ClassNameHasher());

// create extras to send to category timing helper
Expand All @@ -291,7 +291,7 @@ private UserSqlSandbox restoreUser(boolean skipFixtures) throws SyncRestoreExcep
try {
UserSqlSandbox sandbox = getSqlSandbox();
FormplayerTransactionParserFactory factory = new FormplayerTransactionParserFactory(sandbox, true);
InputStream restoreStream = getRestoreXml(skipFixtures);
InputStream restoreStream = getRestoreXml();

SimpleTimer parseTimer = new SimpleTimer();
parseTimer.start();
Expand Down Expand Up @@ -437,9 +437,9 @@ public boolean isRestoreXmlExpired() {
}

@Trace
public InputStream getRestoreXml(boolean skipFixtures) {
public InputStream getRestoreXml() {
ensureValidParameters();
URI url = getRestoreUrl(skipFixtures);
URI url = getRestoreUrl();
recordSentryData(url.toString());
InputStream restoreStream = getRestoreXmlHelper(url);
setLastSyncTime();
Expand Down Expand Up @@ -621,13 +621,13 @@ private Map<String, String> getOriginTokenHeader() {
return Collections.singletonMap("X-CommCareHQ-Origin-Token", originToken);
}

public URI getRestoreUrl(boolean skipFixtures) {
public URI getRestoreUrl() {
// TODO: remove timing once the state hash rollout is complete
return categoryTimingHelper.timed(Constants.TimingCategories.BUILD_RESTORE_URL, () -> {
if (caseId != null) {
return getCaseRestoreUrl();
}
return getUserRestoreUrl(skipFixtures);
return getUserRestoreUrl();
});
}

Expand Down Expand Up @@ -660,7 +660,7 @@ public URI getCaseRestoreUrl() {
return UriComponentsBuilder.fromHttpUrl(caseRestoreUrl).buildAndExpand(domain, caseId).toUri();
}

public URI getUserRestoreUrl(boolean skipFixtures) {
public URI getUserRestoreUrl() {
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(restoreUrl).encode();

Map<String, String> params = new LinkedHashMap<>();
Expand Down Expand Up @@ -690,9 +690,6 @@ public URI getUserRestoreUrl(boolean skipFixtures) {
// HQ requesting to force a sync for a user
params.put("as", username);
}
if (skipFixtures) {
params.put("skip_fixtures", "true");
}

// add the params to the query builder as templates
params.forEach((key, value) -> builder.queryParam(key, String.format("{%s}", key)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class FormplayerPropertyManager extends PropertyManager {
public static final String POST_FORM_SYNC = "cc-sync-after-form";
public static final String FUZZY_SEARCH_ENABLED = "cc-fuzzy-search-enabled";

public static final String SKIP_FIXTURES_AFTER_SUBMIT = "cc-skip-fixtures-after-submit";
public static final String AUTO_ADVANCE_MENU = "cc-auto-advance-menu";

public static final String INDEX_CASE_SEARCH_RESULTS = "cc-index-case-search-results";
Expand Down Expand Up @@ -60,10 +59,6 @@ public boolean isFuzzySearchEnabled() {
return doesPropertyMatch(FUZZY_SEARCH_ENABLED, NO, YES);
}

public boolean skipFixturesAfterSubmit() {
return doesPropertyMatch(SKIP_FIXTURES_AFTER_SUBMIT, NO, YES);
}

public boolean isAutoAdvanceMenu() {
return doesPropertyMatch(AUTO_ADVANCE_MENU, NO, YES);
}
Expand Down

0 comments on commit 2f859f2

Please sign in to comment.