diff --git a/r/shroomDK/.Rhistory b/r/shroomDK/.Rhistory new file mode 100644 index 0000000..e69de29 diff --git a/r/shroomDK/DESCRIPTION b/r/shroomDK/DESCRIPTION index 75221b9..a4d167e 100644 --- a/r/shroomDK/DESCRIPTION +++ b/r/shroomDK/DESCRIPTION @@ -1,7 +1,7 @@ Package: shroomDK Type: Package Title: Accessing the Flipside Crypto ShroomDK API -Version: 0.2.2 +Version: 0.3.0 Author: Carlos Mercado Maintainer: Carlos Mercado Description: Programmatic access to Flipside Crypto data via the Compass RPC API: . As simple as auto_paginate_query() but with core functions as needed for troubleshooting. Note, 0.1.1 support deprecated 2023-05-31. diff --git a/r/shroomDK/R/auto_paginate_query.R b/r/shroomDK/R/auto_paginate_query.R index 24b4076..3ad6167 100644 --- a/r/shroomDK/R/auto_paginate_query.R +++ b/r/shroomDK/R/auto_paginate_query.R @@ -46,7 +46,19 @@ auto_paginate_query <- function(query, api_key, query_status <- get_query_status(query_run_id = query_run_id, api_key = api_key, api_url = api_url) query_state <- query_status$result$queryRun$state - if(query_state == "QUERY_STATE_SUCCESS"){ + failed_to_get_a_state = 0 + + if(failed_to_get_a_state > 2){ + warning("Query has failed state more than twice, consider cancel_query(), exiting now") + stop("Exited due to 3+ Failed States") + } + + if(length(query_state) == 0){ + warning("Query failed to return a state, trying again") + Sys.sleep(5) + failed_to_get_a_state = failed_to_get_a_state + 1 + } else { + if(query_state == "QUERY_STATE_SUCCESS"){ status_check_done <- TRUE result_num_rows <- query_status$result$queryRun$rowCount result_file_size <- as.numeric(query_status$result$queryRun$totalSize) @@ -64,6 +76,7 @@ auto_paginate_query <- function(query, api_key, ) Sys.sleep(10) } + } } if(is.null(page_count)){ diff --git a/r/shroomDK/R/create_query_token.R b/r/shroomDK/R/create_query_token.R index f399bde..f10597d 100644 --- a/r/shroomDK/R/create_query_token.R +++ b/r/shroomDK/R/create_query_token.R @@ -63,7 +63,7 @@ create_query_token <- function(query, api_key, "sql" = query, "tags" = list( "sdk_package" = "R", - "sdk_version" = "0.2.1", + "sdk_version" = "0.3.0", "sdk_language" = "R" ), "dataSource" = data_source, diff --git a/r/shroomDK/R/get_query_from_token.R b/r/shroomDK/R/get_query_from_token.R index 71adc4f..b8f81ab 100644 --- a/r/shroomDK/R/get_query_from_token.R +++ b/r/shroomDK/R/get_query_from_token.R @@ -36,8 +36,19 @@ get_query_from_token <- function(query_run_id, api_key, while (!status_check_done) { query_status <- get_query_status(query_run_id = query_run_id, api_key = api_key, api_url = api_url) query_state <- query_status$result$queryRun$state + failed_to_get_a_state = 0 - if(query_state == "QUERY_STATE_SUCCESS"){ + if(failed_to_get_a_state > 2){ + warning("Query has failed state more than twice, consider cancel_query(), exiting now") + stop("Exited due to 3+ Failed States") + } + + if(length(query_state) == 0){ + warning("Query failed to return a state, trying again") + Sys.sleep(5) + failed_to_get_a_state = failed_to_get_a_state + 1 + } else { + if(query_state == "QUERY_STATE_SUCCESS"){ status_check_done <- TRUE next() } else if(query_state == "QUERY_STATE_FAILED"){ @@ -47,10 +58,20 @@ get_query_from_token <- function(query_run_id, api_key, status_check_done <- TRUE stop("This query was canceled, typically by cancel_query()") } else if(query_state != "QUERY_STATE_SUCCESS"){ - warning("Query in process, checking again in 5 seconds, use cancel_query() if needed.") + warning( + paste0("Query in process, checking again in 10 seconds.", + "To cancel use: cancel_query() with your ID: \n", query_run_id) + ) Sys.sleep(5) + } else if(query_state != "QUERY_STATE_SUCCESS"){ + warning( + paste0("Query in process, checking again in 10 seconds.", + "To cancel use: cancel_query() with your ID: \n", query_run_id) + ) + Sys.sleep(10) } } + } headers = c( "Content-Type" = 'application/json', diff --git a/r/shroomDK_0.2.2.tar.gz b/r/shroomDK_0.2.2.tar.gz deleted file mode 100644 index 7207aca..0000000 Binary files a/r/shroomDK_0.2.2.tar.gz and /dev/null differ diff --git a/r/shroomDK_0.3.0.tar.gz b/r/shroomDK_0.3.0.tar.gz new file mode 100644 index 0000000..89b64fa Binary files /dev/null and b/r/shroomDK_0.3.0.tar.gz differ