From c899c89447128225b8eaff03cb625f95eb21e5fc Mon Sep 17 00:00:00 2001 From: Are Edvardsen Date: Wed, 17 Nov 2021 12:05:01 +0000 Subject: [PATCH 01/15] upping --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 52b2791e..874d6b1e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: rapbase Type: Package Title: Base Functions and Resources for Rapporteket -Version: 1.20.1 +Version: 1.20.2 Authors@R: c( person(given = "Are", family = "Edvardsen", diff --git a/NEWS.md b/NEWS.md index 97366c9b..5835ba58 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# rapbase 1.20.2 + +* Fix short-term error in function finding next run date in auto reports + # rapbase 1.20.1 * Fix unit testing issue by also allowing "MockShinySession" as an attribute of the shiny session object From 4fd4bc4f8d9c354024d67e865070222605093ea6 Mon Sep 17 00:00:00 2001 From: Are Edvardsen Date: Wed, 17 Nov 2021 13:45:01 +0000 Subject: [PATCH 02/15] next run within same year --- R/AutoReportFuns.R | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/R/AutoReportFuns.R b/R/AutoReportFuns.R index 82fcc526..a9c2ba83 100644 --- a/R/AutoReportFuns.R +++ b/R/AutoReportFuns.R @@ -666,8 +666,27 @@ findNextRunDate <- function(runDayOfYear, nextDayNum <- min(runDayOfYear) year <- year + 1 } else { - # next run will be next run day this year - nextDayNum <- min(runDayOfYear[runDayOfYear > baseDayNum]) + # next run will be next run day of current year + ## find year transition, if any + nDay <- length(runDayOfYear) + deltaDay <- runDayOfYear[2:nDay] - runDayOfYear[1:(nDay - 1)] + trans <- deltaDay < 0 + if (any(trans)) { + indTrans <- match(TRUE, trans) + d0 <- runDayOfYear[1:indTrans] + d1 <- runDayOfYear[(indTrans + 1):nDay] + if (baseDayNum >= max(d0)) { + ## use vector TAIL to find next run day + runDayOfCurrentYear <- d1 + } else { + ## use vector HEAD to find next run day + runDayOfCurrentYear <- d0 + } + } else { + runDayOfCurrentYear <- runDayOfYear + } + + nextDayNum <- min(runDayOfCurrentYear[runDayOfCurrentYear > baseDayNum]) } format(strptime(paste(year, nextDayNum), "%Y %j"), format = returnFormat) From 2d9f335ff02b8cfccf1009956ab191a563307dc4 Mon Sep 17 00:00:00 2001 From: Are Edvardsen Date: Thu, 18 Nov 2021 13:57:11 +0000 Subject: [PATCH 03/15] adjust (partially), with tests --- R/AutoReportFuns.R | 24 +++++++++++++++------ tests/testthat/test-auto-report-functions.R | 20 ++++++++++++++++- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/R/AutoReportFuns.R b/R/AutoReportFuns.R index a9c2ba83..ca0f0a03 100644 --- a/R/AutoReportFuns.R +++ b/R/AutoReportFuns.R @@ -673,14 +673,24 @@ findNextRunDate <- function(runDayOfYear, trans <- deltaDay < 0 if (any(trans)) { indTrans <- match(TRUE, trans) - d0 <- runDayOfYear[1:indTrans] - d1 <- runDayOfYear[(indTrans + 1):nDay] - if (baseDayNum >= max(d0)) { - ## use vector TAIL to find next run day - runDayOfCurrentYear <- d1 + # vector head + dHead <- runDayOfYear[1:indTrans] + # vector tail + dTail <- runDayOfYear[(indTrans + 1):nDay] + # by day number, which vector is first (and last) + if (max(dHead) > max(dTail)) { + dFirst <- dTail + dLast <-dHead } else { - ## use vector HEAD to find next run day - runDayOfCurrentYear <- d0 + dFirst <- dHead + dLast <- dTail + } + if (baseDayNum >= max(dFirst)) { + ## next run day to be found among later days + runDayOfCurrentYear <- dLast + } else { + ## next run day to be found among the early days + runDayOfCurrentYear <- dFirst } } else { runDayOfCurrentYear <- runDayOfYear diff --git a/tests/testthat/test-auto-report-functions.R b/tests/testthat/test-auto-report-functions.R index eda685e1..c713b855 100644 --- a/tests/testthat/test-auto-report-functions.R +++ b/tests/testthat/test-auto-report-functions.R @@ -106,7 +106,7 @@ test_that("A year-day sequence can be mande", { expect_true(is.numeric(rdoy)) }) -test_that("The next run day in sequence can be identified", { +test_that("The next run day in simple sequence can be identified", { expect_equal(as.numeric( findNextRunDate( runDayOfYear = c(10, 20, 30), baseDayNum = 11, @@ -124,6 +124,24 @@ test_that("The next run day in sequence can be identified when next year", { ), 10) }) +test_that("for within year-break sequence, next is found among earlier days", { + expect_equal(as.numeric( + findNextRunDate( + runDayOfYear = c(200, 300, 1, 100), baseDayNum = 10, + returnFormat = "%j" + ) + ), 100) +}) + +test_that("for within year-break sequence, next is found among later days", { + expect_equal(as.numeric( + findNextRunDate( + runDayOfYear = c(200, 300, 1, 100), baseDayNum = 110, + returnFormat = "%j" + ) + ), 200) +}) + shinySession <- list(user = "tester") shinySession$groups <- "rapbase" attr(shinySession, "class") <- "ShinySession" From d6fb67043585c9c7a849c3ff9688d0bb0a332bab Mon Sep 17 00:00:00 2001 From: Are Edvardsen Date: Thu, 18 Nov 2021 14:21:41 +0000 Subject: [PATCH 04/15] relate to a startDate soon to be part of ar config --- R/AutoReportFuns.R | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/R/AutoReportFuns.R b/R/AutoReportFuns.R index ca0f0a03..62f7b6e7 100644 --- a/R/AutoReportFuns.R +++ b/R/AutoReportFuns.R @@ -657,9 +657,18 @@ makeRunDayOfYearSequence <- function(startDay = Sys.Date(), interval) { findNextRunDate <- function(runDayOfYear, baseDayNum = as.POSIXlt(Sys.Date())$yday + 1, + startDate = NULL, returnFormat = "%A %e. %B %Y") { + year <- as.POSIXlt(Sys.Date())$year + 1900 + if (!is.null(startDate)) { + if (as.Date(startDate) > as.Date(strptime(paste(year, baseDayNum), + "%Y %j"))) { + baseDayNum <- as.POSIXlt(startDate)$yday + 1 + } + } + if (baseDayNum >= max(runDayOfYear) | length(runDayOfYear) == 1 & baseDayNum >= max(runDayOfYear)) { # next run will be first run of next year @@ -677,7 +686,7 @@ findNextRunDate <- function(runDayOfYear, dHead <- runDayOfYear[1:indTrans] # vector tail dTail <- runDayOfYear[(indTrans + 1):nDay] - # by day number, which vector is first (and last) + # by day number, which vector is first (and last)? if (max(dHead) > max(dTail)) { dFirst <- dTail dLast <-dHead From cb5773c13659d430fb7aa3b1d902effc23af64c4 Mon Sep 17 00:00:00 2001 From: Are Edvardsen Date: Thu, 18 Nov 2021 14:38:51 +0000 Subject: [PATCH 05/15] upgrade (old) with new field --- R/AutoReportFuns.R | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/R/AutoReportFuns.R b/R/AutoReportFuns.R index 62f7b6e7..3db47b25 100644 --- a/R/AutoReportFuns.R +++ b/R/AutoReportFuns.R @@ -159,6 +159,7 @@ upgradeAutoReportData <- function(config) { upgradeType <- FALSE upgradeOwnerName <- FALSE upgradeParams <- FALSE + upgradeStartDate <- FALSE for (i in seq_len(length(config))) { rep <- config[[i]] @@ -180,6 +181,10 @@ upgradeAutoReportData <- function(config) { } config[[i]]$params <- as.list(stats::setNames(paramValue, paramName)) } + if (!"startDate" %in% names(rep)) { + upgradeStartDate <- TRUE + config[[i]]$startDate <- Sys.Date() + } } if (upgradeType) { @@ -203,6 +208,12 @@ upgradeAutoReportData <- function(config) { "registries are still working as expected." )) } + if (upgradeStartDate) { + message(paste( + "Auto report data were upgraded:", + "auto reports with no start date defined now set to the current date." + )) + } config } From d505010b4a8ce832250816aa484424c2cdc802cf Mon Sep 17 00:00:00 2001 From: Are Edvardsen Date: Thu, 18 Nov 2021 14:39:27 +0000 Subject: [PATCH 06/15] create new field in auto report --- R/AutoReportFuns.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/AutoReportFuns.R b/R/AutoReportFuns.R index 3db47b25..d3528450 100644 --- a/R/AutoReportFuns.R +++ b/R/AutoReportFuns.R @@ -45,6 +45,7 @@ createAutoReport <- function(synopsis, package, type = "subscription", fun, paramNames, paramValues, owner, ownerName = "", email, organization, runDayOfYear, + startDate = as.character(Sys.Date()), terminateDate = NULL, interval = "", intervalName = "", dryRun = FALSE) { @@ -75,6 +76,7 @@ createAutoReport <- function(synopsis, package, type = "subscription", fun, l$ownerName <- ownerName l$email <- email l$organization <- organization + l$startDate <- startDate l$terminateDate <- as.character(terminateDate) l$interval <- interval l$intervalName <- intervalName From 8c1285751946b09023baff4108598320566e628b Mon Sep 17 00:00:00 2001 From: Are Edvardsen Date: Fri, 19 Nov 2021 14:19:24 +0000 Subject: [PATCH 07/15] test when start date ahead of time --- R/AutoReportFuns.R | 3 ++- tests/testthat/test-auto-report-functions.R | 23 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/R/AutoReportFuns.R b/R/AutoReportFuns.R index d3528450..ef5b9b8e 100644 --- a/R/AutoReportFuns.R +++ b/R/AutoReportFuns.R @@ -678,7 +678,8 @@ findNextRunDate <- function(runDayOfYear, if (!is.null(startDate)) { if (as.Date(startDate) > as.Date(strptime(paste(year, baseDayNum), "%Y %j"))) { - baseDayNum <- as.POSIXlt(startDate)$yday + 1 + # since we pull the NEXT run day set new base day on day BEFORE star date + baseDayNum <- as.POSIXlt(startDate)$yday } } diff --git a/tests/testthat/test-auto-report-functions.R b/tests/testthat/test-auto-report-functions.R index c713b855..d410b5f5 100644 --- a/tests/testthat/test-auto-report-functions.R +++ b/tests/testthat/test-auto-report-functions.R @@ -25,7 +25,8 @@ test_that("auto report config can be upgraded", { }) test_that("already upgraded auto report config is left as is", { - c <- list(list(type = "subscription", ownerName = "Tore Tester")) + c <- list(list(type = "subscription", ownerName = "Tore Tester", + startDate = "2021-11-19")) expect_equal(c, upgradeAutoReportData(c)) }) @@ -142,6 +143,26 @@ test_that("for within year-break sequence, next is found among later days", { ), 200) }) +test_that("a start date is enforced when given", { + todayNum <- as.POSIXlt(Sys.Date())$yday + 1 + # sequence of 4 consecutive days from, but not including, today + days <- + as.POSIXlt(seq.Date(Sys.Date(), (Sys.Date() + 3), by = "day"))$yday + 2 + expect_equal(as.numeric( + findNextRunDate( + runDayOfYear = days, baseDayNum = todayNum, + returnFormat = "%j" + ) + ), days[1]) + startDate <- Sys.Date() + 4 + expect_equal(as.numeric( + findNextRunDate( + runDayOfYear = days, baseDayNum = todayNum, startDate = startDate, + returnFormat = "%j" + ) + ), days[4]) +}) + shinySession <- list(user = "tester") shinySession$groups <- "rapbase" attr(shinySession, "class") <- "ShinySession" From 6452f2d249c38f36a8d55731fb9e4c231fae9892 Mon Sep 17 00:00:00 2001 From: Are Edvardsen Date: Fri, 19 Nov 2021 14:33:27 +0000 Subject: [PATCH 08/15] new field --- R/autoReport.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/autoReport.R b/R/autoReport.R index 0c855e1b..5ae62203 100644 --- a/R/autoReport.R +++ b/R/autoReport.R @@ -287,6 +287,7 @@ autoReportServer <- function(id, registryName, type, org = NULL, interval = interval, startDay = input$start ), + startDate = input$start, interval = interval, intervalName = strsplit(input$freq, "-")[[1]][1] ) From 1c1386097170f918bad77c5dba5a8bfef8c87c0a Mon Sep 17 00:00:00 2001 From: Are Edvardsen Date: Fri, 19 Nov 2021 14:41:50 +0000 Subject: [PATCH 09/15] add a year limit to available start dates --- R/autoReport.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/autoReport.R b/R/autoReport.R index 5ae62203..e84826c7 100644 --- a/R/autoReport.R +++ b/R/autoReport.R @@ -387,7 +387,9 @@ autoReportServer <- function(id, registryName, type, org = NULL, ), value = seq.Date(Sys.Date(), by = strsplit(input$freq, "-")[[1]][2], - length.out = 2)[2] + length.out = 2)[2], + min = Sys.Date(), + max = seq.Date(Sys.Date(), length.out = 2, by = "1 years")[2] - 1 ) }) From 89adacf321b661443ceb7016c97872091d7eaa43 Mon Sep 17 00:00:00 2001 From: Are Edvardsen Date: Mon, 22 Nov 2021 07:39:42 +0000 Subject: [PATCH 10/15] not today --- R/autoReport.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/autoReport.R b/R/autoReport.R index e84826c7..e7967740 100644 --- a/R/autoReport.R +++ b/R/autoReport.R @@ -388,7 +388,7 @@ autoReportServer <- function(id, registryName, type, org = NULL, value = seq.Date(Sys.Date(), by = strsplit(input$freq, "-")[[1]][2], length.out = 2)[2], - min = Sys.Date(), + min = Sys.Date() + 1, max = seq.Date(Sys.Date(), length.out = 2, by = "1 years")[2] - 1 ) }) From 0e6215c4c49764062e36a23cd53471ee89131a8f Mon Sep 17 00:00:00 2001 From: Are Edvardsen Date: Mon, 22 Nov 2021 08:46:10 +0000 Subject: [PATCH 11/15] provide start date when making auto report tab --- R/AutoReportFuns.R | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/R/AutoReportFuns.R b/R/AutoReportFuns.R index ef5b9b8e..47d286f6 100644 --- a/R/AutoReportFuns.R +++ b/R/AutoReportFuns.R @@ -25,6 +25,8 @@ #' @param organization String identifying the organization the owner belongs to #' @param runDayOfYear Integer vector with day numbers of the year when the #' report is to be run +#' @param startDate Date-class date when report will be run first time. Default +#' value is set to \code{Sys.Date() + 1} \emph{i.e.} tomorrow. #' @param terminateDate Date-class date after which report is no longer run. #' Default value set to \code{NULL} in which case the function will provide an #' expiry date adding 3 years to the current date if in a PRODUCTION context @@ -76,7 +78,7 @@ createAutoReport <- function(synopsis, package, type = "subscription", fun, l$ownerName <- ownerName l$email <- email l$organization <- organization - l$startDate <- startDate + l$startDate <- as.character(startDate) l$terminateDate <- as.character(terminateDate) l$interval <- interval l$intervalName <- intervalName @@ -680,6 +682,7 @@ findNextRunDate <- function(runDayOfYear, "%Y %j"))) { # since we pull the NEXT run day set new base day on day BEFORE star date baseDayNum <- as.POSIXlt(startDate)$yday + print(paste("Start date is ahead of base day:", startDate, baseDayNum)) } } @@ -711,9 +714,11 @@ findNextRunDate <- function(runDayOfYear, if (baseDayNum >= max(dFirst)) { ## next run day to be found among later days runDayOfCurrentYear <- dLast + print("Next run day picked from later days") } else { ## next run day to be found among the early days runDayOfCurrentYear <- dFirst + print("Next run day picked from earlier days") } } else { runDayOfCurrentYear <- runDayOfYear @@ -794,7 +799,9 @@ makeAutoReportTab <- function(session, namespace = character(), dateFormat <- "%A %e. %B %Y" for (n in names(autoRep)) { - nextDate <- findNextRunDate(autoRep[[n]]$runDayOfYear, + nextDate <- findNextRunDate( + runDayOfYear = autoRep[[n]]$runDayOfYear, + startDate = autoRep[[n]]$startDate, returnFormat = dateFormat ) if (as.Date(nextDate, format = dateFormat) > autoRep[[n]]$terminateDate) { From b76662e1281e143fb1361e28481cd683d3ca0c9f Mon Sep 17 00:00:00 2001 From: Are Edvardsen Date: Mon, 22 Nov 2021 09:45:00 +0000 Subject: [PATCH 12/15] still may need to add year --- R/AutoReportFuns.R | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/R/AutoReportFuns.R b/R/AutoReportFuns.R index 47d286f6..c9d5a4f9 100644 --- a/R/AutoReportFuns.R +++ b/R/AutoReportFuns.R @@ -692,8 +692,7 @@ findNextRunDate <- function(runDayOfYear, nextDayNum <- min(runDayOfYear) year <- year + 1 } else { - # next run will be next run day of current year - ## find year transition, if any + # find year transition, if any nDay <- length(runDayOfYear) deltaDay <- runDayOfYear[2:nDay] - runDayOfYear[1:(nDay - 1)] trans <- deltaDay < 0 @@ -703,28 +702,29 @@ findNextRunDate <- function(runDayOfYear, dHead <- runDayOfYear[1:indTrans] # vector tail dTail <- runDayOfYear[(indTrans + 1):nDay] - # by day number, which vector is first (and last)? - if (max(dHead) > max(dTail)) { - dFirst <- dTail - dLast <-dHead - } else { - dFirst <- dHead - dLast <- dTail + + # if current date part of head and base day num part of tail next run will + # be next year + if (as.numeric(format(Sys.Date(), "%j")) > max(dTail) & + baseDayNum < max(dTail)) { + year <- year + 1 + print("Next run date will be next year") } - if (baseDayNum >= max(dFirst)) { - ## next run day to be found among later days - runDayOfCurrentYear <- dLast - print("Next run day picked from later days") + + if (baseDayNum >= max(dTail)) { + ## next run day to be found in vector head + runDayOfYearSubset <- dHead + print("Next run day picked from head") } else { - ## next run day to be found among the early days - runDayOfCurrentYear <- dFirst - print("Next run day picked from earlier days") + ## next run day to be found in vector tail + runDayOfYearSubset <- dTail + print("Next run day picked from tail") } } else { - runDayOfCurrentYear <- runDayOfYear + runDayOfYearSubset <- runDayOfYear } - nextDayNum <- min(runDayOfCurrentYear[runDayOfCurrentYear > baseDayNum]) + nextDayNum <- min(runDayOfYearSubset[runDayOfYearSubset > baseDayNum]) } format(strptime(paste(year, nextDayNum), "%Y %j"), format = returnFormat) From 70fd7691c44e69a48346ecf0366ec8b3bd6a4fc3 Mon Sep 17 00:00:00 2001 From: Are Edvardsen Date: Mon, 22 Nov 2021 11:42:10 +0000 Subject: [PATCH 13/15] generic year transition --- R/AutoReportFuns.R | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/R/AutoReportFuns.R b/R/AutoReportFuns.R index c9d5a4f9..65c14aa1 100644 --- a/R/AutoReportFuns.R +++ b/R/AutoReportFuns.R @@ -686,11 +686,10 @@ findNextRunDate <- function(runDayOfYear, } } - if (baseDayNum >= max(runDayOfYear) | length(runDayOfYear) == 1 & - baseDayNum >= max(runDayOfYear)) { - # next run will be first run of next year + # special case if out of max range and only one run day defined (yearly) + if (baseDayNum >= max(runDayOfYear) | length(runDayOfYear) == 1) { + # next run will be first run in day num vector nextDayNum <- min(runDayOfYear) - year <- year + 1 } else { # find year transition, if any nDay <- length(runDayOfYear) @@ -703,14 +702,6 @@ findNextRunDate <- function(runDayOfYear, # vector tail dTail <- runDayOfYear[(indTrans + 1):nDay] - # if current date part of head and base day num part of tail next run will - # be next year - if (as.numeric(format(Sys.Date(), "%j")) > max(dTail) & - baseDayNum < max(dTail)) { - year <- year + 1 - print("Next run date will be next year") - } - if (baseDayNum >= max(dTail)) { ## next run day to be found in vector head runDayOfYearSubset <- dHead @@ -727,6 +718,12 @@ findNextRunDate <- function(runDayOfYear, nextDayNum <- min(runDayOfYearSubset[runDayOfYearSubset > baseDayNum]) } + # if current day num larger than nextDayNum report will be run next year + if (as.numeric(format(Sys.Date(), "%j")) > nextDayNum) { + year <- year + 1 + print("Next run date will be next year") + } + format(strptime(paste(year, nextDayNum), "%Y %j"), format = returnFormat) } From 6b9c82a4b24950ff1e137b7b95053e79970898fd Mon Sep 17 00:00:00 2001 From: Are Edvardsen Date: Mon, 22 Nov 2021 11:59:44 +0000 Subject: [PATCH 14/15] clean up and doc --- R/AutoReportFuns.R | 8 ++++---- man/createAutoReport.Rd | 4 ++++ man/findNextRunDate.Rd | 6 ++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/R/AutoReportFuns.R b/R/AutoReportFuns.R index 65c14aa1..87535c94 100644 --- a/R/AutoReportFuns.R +++ b/R/AutoReportFuns.R @@ -660,6 +660,10 @@ makeRunDayOfYearSequence <- function(startDay = Sys.Date(), interval) { #' #' @param runDayOfYear Numeric vector providing year-day numbers #' @param baseDayNum Numeric defining base year-day. Default is today +#' @param startDate Character string of format "YYYY-MM-DD" defining the date of +#' the very first run. If set to NULL (default) or a none future date (compared +#' to the date represented by \code{baseDayNum} for the current year) it will be +#' disregarded. #' @param returnFormat String providing return format as described in #' \code{\link[base]{strptime}} in the current locale. Defaults to #' "\%A \%d. \%B \%Y" that will provide something like @@ -682,7 +686,6 @@ findNextRunDate <- function(runDayOfYear, "%Y %j"))) { # since we pull the NEXT run day set new base day on day BEFORE star date baseDayNum <- as.POSIXlt(startDate)$yday - print(paste("Start date is ahead of base day:", startDate, baseDayNum)) } } @@ -705,11 +708,9 @@ findNextRunDate <- function(runDayOfYear, if (baseDayNum >= max(dTail)) { ## next run day to be found in vector head runDayOfYearSubset <- dHead - print("Next run day picked from head") } else { ## next run day to be found in vector tail runDayOfYearSubset <- dTail - print("Next run day picked from tail") } } else { runDayOfYearSubset <- runDayOfYear @@ -721,7 +722,6 @@ findNextRunDate <- function(runDayOfYear, # if current day num larger than nextDayNum report will be run next year if (as.numeric(format(Sys.Date(), "%j")) > nextDayNum) { year <- year + 1 - print("Next run date will be next year") } format(strptime(paste(year, nextDayNum), "%Y %j"), format = returnFormat) diff --git a/man/createAutoReport.Rd b/man/createAutoReport.Rd index 010419af..b89dbdb6 100644 --- a/man/createAutoReport.Rd +++ b/man/createAutoReport.Rd @@ -16,6 +16,7 @@ createAutoReport( email, organization, runDayOfYear, + startDate = as.character(Sys.Date()), terminateDate = NULL, interval = "", intervalName = "", @@ -52,6 +53,9 @@ report} \item{runDayOfYear}{Integer vector with day numbers of the year when the report is to be run} +\item{startDate}{Date-class date when report will be run first time. Default +value is set to \code{Sys.Date() + 1} \emph{i.e.} tomorrow.} + \item{terminateDate}{Date-class date after which report is no longer run. Default value set to \code{NULL} in which case the function will provide an expiry date adding 3 years to the current date if in a PRODUCTION context diff --git a/man/findNextRunDate.Rd b/man/findNextRunDate.Rd index 7b11640f..7068b8bb 100644 --- a/man/findNextRunDate.Rd +++ b/man/findNextRunDate.Rd @@ -7,6 +7,7 @@ findNextRunDate( runDayOfYear, baseDayNum = as.POSIXlt(Sys.Date())$yday + 1, + startDate = NULL, returnFormat = "\%A \%e. \%B \%Y" ) } @@ -15,6 +16,11 @@ findNextRunDate( \item{baseDayNum}{Numeric defining base year-day. Default is today} +\item{startDate}{Character string of format "YYYY-MM-DD" defining the date of +the very first run. If set to NULL (default) or a none future date (compared +to the date represented by \code{baseDayNum} for the current year) it will be +disregarded.} + \item{returnFormat}{String providing return format as described in \code{\link[base]{strptime}} in the current locale. Defaults to "\%A \%d. \%B \%Y" that will provide something like From 4583c95568842a3c24642101481a1eb54736328c Mon Sep 17 00:00:00 2001 From: Are Edvardsen Date: Mon, 22 Nov 2021 12:14:21 +0000 Subject: [PATCH 15/15] new auto report field in dummy data --- inst/autoReport.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/inst/autoReport.yml b/inst/autoReport.yml index 90426c47..5d7eb34d 100644 --- a/inst/autoReport.yml +++ b/inst/autoReport.yml @@ -12,6 +12,7 @@ testAutoReportFirst: - Some One - Jesus organization: '999999' + startDate: '1900-01-01' terminateDate: '9999-12-31' interval: intervalName: @@ -30,6 +31,7 @@ testAutoReportSecond: owner: ttester email: organization: '999999' + startDate: '1900-01-01' terminateDate: '9999-12-31' interval: intervalName: @@ -53,6 +55,7 @@ testAutoReportThird: - - jesus@sky.com organization: '999999' + startDate: '1900-01-01' terminateDate: '9999-12-31' interval: intervalName: @@ -71,6 +74,7 @@ testAutoReportThird: owner: ttester email: tester@skde.no organization: '999999' + startDate: '1900-01-01' terminateDate: '9999-12-31' interval: intervalName: @@ -86,6 +90,7 @@ cd467ac14dd848b8798a384a3e51512c: owner: ttester email: tester@skde.no organization: '999999' + startDate: '1900-01-01' terminateDate: '0000-01-01' interval: intervalName: