From bc023ce7bf236a219f2146a2fa5238318912e4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Mon, 18 Apr 2016 16:25:41 -0700 Subject: [PATCH] fix R CMD check warnings --- R/filter.R | 4 ++-- R/query.R | 8 ++++---- R/utilities-query.R | 4 ++-- R/utilities-time.R | 2 +- man/grapes-equals-grapes-.druid.dimension.Rd | 2 +- tests/{test-all.R => testthat.R} | 6 ++---- {inst/tests => tests/testthat}/test-query.R | 3 ++- .../tests => tests/testthat}/test-utilities-time.R | 14 +++++++------- 8 files changed, 21 insertions(+), 22 deletions(-) rename tests/{test-all.R => testthat.R} (93%) rename {inst/tests => tests/testthat}/test-query.R (94%) rename {inst/tests => tests/testthat}/test-utilities-time.R (95%) diff --git a/R/filter.R b/R/filter.R index 0c44e65..4e46bf8 100644 --- a/R/filter.R +++ b/R/filter.R @@ -58,9 +58,9 @@ selector <- function(...) { #' @param x character vector of possible values to match #' @method %=% druid.dimension #' @export -`%=%.druid.dimension` <- function(dimension, x) { +`%=%.druid.dimension` <- function(dimension, pattern) { stopifnot(is(dimension, "druid.dimension")) - filters <- plyr::llply(x, function(v) { + filters <- plyr::llply(pattern, function(v) { druid.filter.selector(dimension = as.character(dimension), value = as.character(v)) }) do.call("druid.filter.or", filters) diff --git a/R/query.R b/R/query.R index eb14949..1e4881e 100644 --- a/R/query.R +++ b/R/query.R @@ -351,19 +351,19 @@ druid.query.topN <- function(url = druid.url(), dataSource, intervals, aggregati # check whether aggregations is a list or a single aggregation object if(is(aggregations, "druid.aggregator")) aggregations <- list(aggregations) - query.js <- RDruid:::json(list(intervals = as.list(toISO(intervals)), - aggregations = RDruid:::renameagg(aggregations), + query.js <- json(list(intervals = as.list(toISO(intervals)), + aggregations = renameagg(aggregations), dataSource = dataSource, filter = filter, granularity = granularity, - postAggregations = RDruid:::renameagg(postAggregations), + postAggregations = renameagg(postAggregations), context = context, queryType = "topN", dimension = dimension, metric = metric, threshold = n), pretty=verbose) if(verbose) { cat(query.js) } - result.l <- RDruid:::query(query.js, url, verbose, ...) + result.l <- query(query.js, url, verbose, ...) if(rawData) { return (result.l) diff --git a/R/utilities-query.R b/R/utilities-query.R index e95849e..a9dcac5 100644 --- a/R/utilities-query.R +++ b/R/utilities-query.R @@ -45,13 +45,13 @@ query <- function(jsonstr, url, verbose = F, benchmark = F, ...){ message(jsonstr) } res <- httr::POST( - url, content_type_json(), + url, httr::content_type_json(), body = jsonstr, verbose = verbose ) } - if(httr::status_code(res) >= 300 && !is.na(pmatch("application/json", headers(res)$`content-type`))) { + if(httr::status_code(res) >= 300 && !is.na(pmatch("application/json", httr::headers(res)$`content-type`))) { err <- fromJSON( httr::content(res, as = "text", type = "application/json", encoding = "UTF-8"), simplifyVector = TRUE diff --git a/R/utilities-time.R b/R/utilities-time.R index eca121b..7fbb1f1 100644 --- a/R/utilities-time.R +++ b/R/utilities-time.R @@ -42,7 +42,7 @@ toISO.character <- function(x) { #' @method toISO numeric #' @export toISO.numeric <- function(x) { - toISO(as.POSIXct(x, origin=origin)) + toISO(as.POSIXct(x, lubridate::origin)) } #' Convert a POSIX* object to its ISO 8601 string representation diff --git a/man/grapes-equals-grapes-.druid.dimension.Rd b/man/grapes-equals-grapes-.druid.dimension.Rd index c297bb4..c1c06ef 100644 --- a/man/grapes-equals-grapes-.druid.dimension.Rd +++ b/man/grapes-equals-grapes-.druid.dimension.Rd @@ -4,7 +4,7 @@ \alias{\%=\%.druid.dimension} \title{Construct a selector filter for a given dimension} \usage{ -\method{\%=\%}{druid.dimension}(dimension, x) +\method{\%=\%}{druid.dimension}(dimension, pattern) } \arguments{ \item{dimension}{dimension to match} diff --git a/tests/test-all.R b/tests/testthat.R similarity index 93% rename from tests/test-all.R rename to tests/testthat.R index e225e4a..fdbd9d8 100644 --- a/tests/test-all.R +++ b/tests/testthat.R @@ -14,9 +14,7 @@ # limitations under the License. # - -library(lubridate) -library(RDruid) library(testthat) +library(RDruid) -test_package("RDruid") +test_check("RDruid") diff --git a/inst/tests/test-query.R b/tests/testthat/test-query.R similarity index 94% rename from inst/tests/test-query.R rename to tests/testthat/test-query.R index 191bdf3..fd576b5 100644 --- a/inst/tests/test-query.R +++ b/tests/testthat/test-query.R @@ -15,7 +15,8 @@ # test_that("groupBy handles missing columns", { - res <- fromJSON('[{"timestamp":"2013-07-01T00:00:00.000Z","version":"v1","event":{"count":10,"col1":"No","col2":"Yes"}},{"timestamp":"2013-07-01T00:00:00.000Z","version":"v1","event":{"count":20,"col1":"Yes"}}]') + res <- fromJSON('[{"timestamp":"2013-07-01T00:00:00.000Z","version":"v1","event":{"count":10,"col1":"No","col2":"Yes"}},{"timestamp":"2013-07-01T00:00:00.000Z","version":"v1","event":{"count":20,"col1":"Yes"}}]', + simplifyVector = F) df <- RDruid:::druid.groupBytodf(res) expected <- data.frame( timestamp = fromISO(c("2013-07-01T00:00:00.000Z", "2013-07-01T00:00:00.000Z")), diff --git a/inst/tests/test-utilities-time.R b/tests/testthat/test-utilities-time.R similarity index 95% rename from inst/tests/test-utilities-time.R rename to tests/testthat/test-utilities-time.R index 9d686f1..133b313 100644 --- a/inst/tests/test-utilities-time.R +++ b/tests/testthat/test-utilities-time.R @@ -18,7 +18,7 @@ test_that("fromISO parses milliseconds", { t <- fromISO("2011-05-01T02:03:00.123") expect_equal(second(t), 0.123, tolerance = 0.0001, scale=1) - + t <- fromISO("2011-05-01T02:03:00.123+05:30") expect_equal(second(t), 0.123, tolerance = 0.0001, scale=1) @@ -31,13 +31,13 @@ test_that("fromISO parses TZ offset", { t <- fromISO("2012-04-01T00:00:00") expect_equal(t, t_exp, tolerance=0.0001, scale=1) - + t <- fromISO("2012-04-01T00:00:00+00:00") expect_equal(t, t_exp, tolerance=0.0001, scale=1) - + t <- fromISO("2012-04-01T05:00:00+05:00") expect_equal(t, t_exp, tolerance=0.0001, scale=1) - + t <- fromISO("2012-04-01T05:30:00+05:30") expect_equal(t, t_exp, tolerance=0.0001, scale=1) @@ -45,7 +45,7 @@ test_that("fromISO parses TZ offset", { expect_equal(t, t_exp, tolerance=0.0001, scale=1) t <- fromISO("2012-03-31T18:30:00-05:30") - expect_equal(t, t_exp, tolerance=0.0001, scale=1) + expect_equal(t, t_exp, tolerance=0.0001, scale=1) }) test_that("fromISO properly works in vector format", { @@ -63,9 +63,9 @@ test_that("toISO prints milliseconds", { test_that("toISO prints interval", { t <- as.POSIXct("2012-01-01", tz="UTC") t1 <- c(t, t + dminutes(30), t + dhours(14)) - t2 <- c(t + dhours(2), t + dhours(3), t + ddays(2)) + t2 <- c(t + dhours(2), t + dhours(3), t + ddays(2)) i <- interval(t1, t2) - + expect_identical(toISO(i), c("2012-01-01T00:00:00.000+00:00/2012-01-01T02:00:00.000+00:00", "2012-01-01T00:30:00.000+00:00/2012-01-01T03:00:00.000+00:00", "2012-01-01T14:00:00.000+00:00/2012-01-03T00:00:00.000+00:00"))