Skip to content

Commit

Permalink
approx date match feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
connorlbark committed Jan 15, 2025
1 parent cfe073e commit 716f6a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions core/src/main/java/bio/terra/pearl/core/dao/BaseJdbiDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,11 @@ protected int countByProperty(String propertyName, Object value) {
);
}

protected String approximateDateMatchQueryStr(String col1, String col2, String maxDifferenceSeconds) {
return "abs(extract(epoch from %s) - extract(epoch from %s)) < %s".formatted(col1, col2, maxDifferenceSeconds);

}

protected String prefixedGetQueryColumns(String prefix) {
List<String> prefixedCols = getQueryColumns.stream().map(col -> prefix + "." + col)
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public Optional<ParticipantTask> findTaskForActivityWithCompletionTime(UUID ppUs
where portal_participant_user_id = :ppUserId
and target_stable_id = :activityStableId
and study_environment_id = :studyEnvironmentId
and ABS(EXTRACT(EPOCH FROM completed_at) - EXTRACT(EPOCH FROM :completedAt::timestamp)) < 43200
and %s
limit 1
""".formatted(tableName)
""".formatted(tableName, approximateDateMatchQueryStr("completed_at", ":completedAt::timestamp", "43200"))
)
.bind("ppUserId", ppUserId)
.bind("activityStableId", activityStableId)
Expand Down

0 comments on commit 716f6a8

Please sign in to comment.