Skip to content

Commit

Permalink
Synchronize data with AWS
Browse files Browse the repository at this point in the history
This pushes up records to AWS. It pivots the JSON on the way, using the case ID as each object's key.
  • Loading branch information
waldoj committed Mar 11, 2023
1 parent 47eb0f2 commit d2f9641
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions sync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

# Delete temporary files on exit
trap 'rm -f "$tmp" "$tmp2"' EXIT

# Rearrange the JSON to use case IDs as keys
tmp=$(mktemp)
jq 'reduce .[] as $item ({}; .[$item.case_id] = $item)' arguments.json > "$tmp"
tmp2=$(mktemp)
jq 'with_entries(.value |= del(.case_id))' "$tmp" > "$tmp2"

# Copy the file
aws s3 cp --no-progress "$tmp2" s3://courtaudio/arguments.json
aws s3 sync --no-progress transcripts/ s3://courtaudio/transcripts/
aws s3 sync --no-progress audio/ s3://courtaudio/audio/ --exclude "*" --include "*.mp3"

# Invalidate the cached JSON
aws cloudfront create-invalidation --distribution-id EM9XCQXYT1OYQ --paths "/arguments.json"

0 comments on commit d2f9641

Please sign in to comment.