Bearloga has uploaded a new change for review. https://gerrit.wikimedia.org/r/264785
Change subject: Enables quick backfilling through system command line Can now backfill by calling: `Rscript backfill_from.R YYYY-MM-DD` in Terminal. If the starting date argument is missing it behaves as classic call to run() in run.R, o.w. it will backfill from YYYY-M ...................................................................... Enables quick backfilling through system command line Can now backfill by calling: `Rscript backfill_from.R YYYY-MM-DD` in Terminal. If the starting date argument is missing it behaves as classic call to run() in run.R, o.w. it will backfill from YYYY-MM-DD to Sys.Date()-1. Requires a change to the cron job since run.R no longer includes a call to run(). Change-Id: I68c224e9f45931146ef7b3f69e84a2f1bc247a57 --- M CHANGELOG.md A backfill_from.R M run.R 3 files changed, 28 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/discovery/golden refs/changes/85/264785/1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 069a91a..d4ef4ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Change Log (Patch Notes) All notable changes to this project will be documented in this file. +## 2016/01/18 +- Adds quick backfilling through system command line + +## 2016/01/15 +- Adds a check for empty dataset returned + ## 2015/11/05 - Reset default tables for user satisfaction metrics - Fix LDN bug diff --git a/backfill_from.R b/backfill_from.R new file mode 100644 index 0000000..219ebaf --- /dev/null +++ b/backfill_from.R @@ -0,0 +1,22 @@ +# Usage: +# +# - For the previous day's data (classic run()): +# $> Rscript backfill_from.R +# +# - To backfill data from a specific date (inclusive): +# $> Rscript backfill_from.R YYYY-MM-DD +# +# This will generate a vector of dates from YYYY-MM-DD to Sys.Date()-1 +# and passes that vector to run() from run.R + +args <- commandArgs(trailingOnly = TRUE) +source("run.R") +if (is.na(args[1])) { + print("No backfilling start date provided. Assuming user wants previous day's data.") + run() +} else { + start_date <- as.Date(args[1]) + end_date <- Sys.Date() - 1 + dates_to_backfill <- seq(start_date, end_date, "day") + run(dates_to_backfill) +} diff --git a/run.R b/run.R index 4da8f28..2a14c57 100644 --- a/run.R +++ b/run.R @@ -57,5 +57,3 @@ return(invisible()) } - -run() -- To view, visit https://gerrit.wikimedia.org/r/264785 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I68c224e9f45931146ef7b3f69e84a2f1bc247a57 Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/discovery/golden Gerrit-Branch: master Gerrit-Owner: Bearloga <mpo...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits