#!/bin/bash

current_date=$2
start_date=$1

report_file_name="primary_unfinished_${start_date}_${current_date}.html"
tsv_file_name="primary_unfinished_${start_date}_${current_date}.tsv"
path_to_report="/mnt/sun-pcs01/ingest/ingest_reports/${report_file_name}"
path_to_tsv="/mnt/sun-pcs01/ingest/ingest_reports/${tsv_file_name}"

bazel run //data/ingest/completeness_check:check_primary -- --start $start_date --end $current_date > "$path_to_tsv"

cat "$path_to_tsv" | python ./data/ingest/completeness_check/make_report.py "$path_to_tsv" "$start_date" "$current_date"> "$path_to_report"

chmod 777 "$path_to_tsv"
chmod 777 "$path_to_report"
