Skip to content

Commit

Permalink
fix continuous flag bug and url checker warning
Browse files Browse the repository at this point in the history
  • Loading branch information
cristinamullin committed Nov 22, 2024
1 parent 6013d13 commit 928e953
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
11 changes: 10 additions & 1 deletion R/ResultFlagsIndependent.R
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,17 @@ TADA_FlagContinuousData <- function(.data, clean = FALSE, flaggedonly = FALSE, t
rm(within_window)
}

flag.data <- cont.data %>%
# check if noncont.data is blank. If TRUE, flag.data = cont.data
if (nrow(noncont.data) == 0) {
print("All data is flagged as continuous in TADA.ContinuousData.Flag column.")
flag.data = cont.data
}

# if noncont.data is NOT blank, flag.data = join of noncont.data with cont.data
if (nrow(noncont.data) != 0) {
flag.data <- cont.data %>%
dplyr::full_join(noncont.data, by = c(names(cont.data)))
}

# flagged output, all data
if (clean == FALSE & flaggedonly == FALSE) {
Expand Down
12 changes: 10 additions & 2 deletions tests/testthat/test-URLChecker.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
test_that("URLs are not broken", {
# ignore warning
# file("") only supports open = "w+" and open = "w+b": using the former
# https://github.com/USEPA/EPATADA/pull/548
suppressWarnings(
test_that("URLs are not broken", {


# extract urls function
extract_urls <- function(text) {
stringr::str_extract_all(text, "http[s]?://[^\\s\\)\\]]+") %>% unlist()
Expand Down Expand Up @@ -34,7 +40,8 @@ test_that("URLs are not broken", {
extract_urls() %>%
clean_url() %>%
unique() %>%
# problematic URL I can't get a response from using multiple methods (itec) and CRAN because its response is inconsistent, likely due to redirecting to mirrors (HRM 10/28/2024)
# problematic URL I can't get a response from using multiple methods (itec)
#and CRAN because its response is inconsistent, likely due to redirecting to mirrors (HRM 10/28/2024)
setdiff(c(
# url works (HRM 11/7/24), but does not provide a recognizable response code
"https://www.itecmembers.org/attains/",
Expand Down Expand Up @@ -68,3 +75,4 @@ test_that("URLs are not broken", {
# verify that there are zero urls with failing response codes
testthat::expect_equal(n, 0)
})
)

0 comments on commit 928e953

Please sign in to comment.