Skip to content

Commit

Permalink
Fix json
Browse files Browse the repository at this point in the history
  • Loading branch information
azimov committed Jan 4, 2024
1 parent f18602a commit 49b187c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions R/CohortDefinitionSet.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ getMockCohortDefinitionSet <- function(rewardConfig, cohortIds) {
cd.cohort_definition_id as cohort_id,
cd.cohort_definition_name as cohort_name,
COALESCE(ar.sql_definition, '') as sql,
COALESCE(ar.definition, '') as json,
COALESCE(ar.definition, '{}') as json,
CASE WHEN ar.definition IS NULL THEN 0 ELSE 1 END as has_json
FROM @schema.@cohort_definition cd
LEFT JOIN @schema.@atlas_cohort_reference ar ON cd.cohort_definition_id = ar.cohort_definition_id
Expand All @@ -35,9 +35,11 @@ getMockCohortDefinitionSet <- function(rewardConfig, cohortIds) {


res <- res %>%
dplyr::mutate(json = ifelse(.data$hasJson == 1, .decodeBase64(.data$json), "{}")) %>%
dplyr::mutate(sql = ifelse(.data$hasJson == 1, .decodeBase64(.data$sql), "")) %>%
dplyr::mutate(json = ifelse(.data$hasJson == 1, .decodeBase64(.data$json), .data$json)) %>%
dplyr::mutate(sql = ifelse(.data$hasJson == 1, .decodeBase64(.data$sql), "SELECT NULL")) %>%
dplyr::select(-"hasJson")


attr(res, "isMockCohortDefinitionSet") <- TRUE
return(res)
}

0 comments on commit 49b187c

Please sign in to comment.