Skip to content

Commit

Permalink
[JN-1580] null-safe instants on enrollee import (#1399)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorlbark authored Jan 22, 2025
1 parent 781c569 commit aebdeb1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ public List<ImportItem> importAccount(AccountImportData accountData, String port
importItems.add(createImportItemFromEnrollee(accountEnrollee, importId));
}
} catch (Exception e) {
importItems.add(createFailedImportItem(importId, e.getMessage(), Arrays.toString(e.getStackTrace()), adminId));
String message = "%s: %s".formatted(e.getClass().getSimpleName(), e.getMessage());

importItems.add(createFailedImportItem(importId, message, Arrays.toString(e.getStackTrace()), adminId));
if (!accountData.getProxyData().isEmpty()) {
log.warn("failed to import primary enrollee, skipping proxy import for username: {}", accountData.getEmail());
}
Expand Down Expand Up @@ -600,7 +602,7 @@ private ParticipantTask findTask(PortalParticipantUser ppUser, StudyEnvironment
.orElse(null);
} else {
if (completedAt.isEmpty()) {
throw new IllegalStateException("completedAt must be specified for importing survey response history");
throw new IllegalStateException("Failed importing %s: completedAt must be specified for importing survey response history".formatted(formatter.getModuleName()));
}
// case 2: completedAt is specified, find task with that completion time
relatedTask = participantTaskService.findTaskForActivityWithCompletionTime(ppUser.getId(), studyEnv.getId(), formatter.getModuleName(), completedAt.get())
Expand Down Expand Up @@ -640,7 +642,7 @@ private void shiftTime(SurveyResponse surveyResponse, ParticipantTask relatedTas
private Optional<Instant> parseSurveyFieldToInstant(SurveyFormatter formatter, Map<String, String> enrolleeMap, Integer repeatNum, String field, ZoneId zoneId) {
String key = formatter.formatColumnKey(repeatNum, field);
if (enrolleeMap.containsKey(key)) {
return Optional.of(ExportFormatUtils.importInstant(enrolleeMap.get(key), zoneId == null ? ZoneId.of("America/New_York") : zoneId));
return Optional.ofNullable(ExportFormatUtils.importInstant(enrolleeMap.get(key), zoneId == null ? ZoneId.of("America/New_York") : zoneId));
}
return Optional.empty();
}
Expand Down
1 change: 1 addition & 0 deletions pepper-import/scripts/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ def parse_juniper_data_dict(filepath: str) -> list[DataDefinition]:

while len(simple_questions) > 0:
question = simple_questions.pop(0)

# subquestion; handled when we encounter the parent question
if question.stable_id.endswith('[0]'):
continue
Expand Down

0 comments on commit aebdeb1

Please sign in to comment.