Skip to content

Commit 1304e6f

Browse files
authored
Update run script to copy a specific range of files to the receiving directory (#575)
* Add vars and one-liner to a specific range of files * Break up long line * Specify directory to list * Add a bit of safety * Remove cruft
1 parent b9cd410 commit 1304e6f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

safegraph_patterns/run-safegraph_patterns.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
#set -eo pipefail
77

8+
# Vars.
9+
# Date of first monday 8 weeks in the past. Taste to suit!
10+
start_day=$(date --date 'monday-56 days' +"%Y%m%d")
11+
today=$(date +"%Y%m%d")
12+
813
# Purge the receiving directory.
914
echo "Purging ./receiving..."
1015
rm -f ./receiving/*
@@ -14,7 +19,11 @@ echo "Running the indicator..."
1419
env/bin/python -m delphi_safegraph_patterns
1520

1621
# Copy the files to the ingestion directory.
22+
# The unwieldy one-liner does the following:
23+
# - Pipe a list of files into awk.
24+
# - awk prints the files that are inclusive of ${start_day} to ${today}.
25+
# - Pipe that list into xargs and copy those files to the receiving dir.
1726
echo "Copying files to the ingestion directory..."
18-
# Hack to make cp care less about missing recent files since we don't always have them.
19-
cp $(date +"receiving/%Y%m*") /common/covidcast/receiving/safegraph 2>/dev/null
20-
cp $(date --date='-1 month' +"receiving/%Y%m*") /common/covidcast/receiving/safegraph
27+
cd ./receiving || exit
28+
ls -1 *.csv | awk '$0>=from && $0<=to' from="${start_day}" to="${today}" \
29+
| xargs cp -t /common/covidcast/receiving/safegraph

0 commit comments

Comments
 (0)