Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions shared-opt-dir/agency-parser/check_data_outdated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,25 @@ fi

echo "> Deployed last departure timestamp: '$DEPLOYED_LAST_DEPARTURE_SEC' (from $DATA_FILE_USED)";

# Check if deployed data is not outdated (last departure is in the future)
if [[ "$DEPLOYED_LAST_DEPARTURE_SEC" -gt "$NOW_TIMESTAMP_SEC" ]]; then
# Check if deployed data is not outdated (last departure is more than 3 days in the future)
THREE_DAYS_SEC=$((3 * 86400));
if [[ "$DEPLOYED_LAST_DEPARTURE_SEC" -gt "$((NOW_TIMESTAMP_SEC + THREE_DAYS_SEC))" ]]; then
DIFF_SEC=$((DEPLOYED_LAST_DEPARTURE_SEC - NOW_TIMESTAMP_SEC));
DIFF_DAYS=$((DIFF_SEC / 86400));
echo ">> Deployed data has not expired. Last departure will be in $DIFF_DAYS days.";
echo ">> Data is not outdated. Sync not recommended.";
exit 0; # Exit code 0 indicates data is not outdated
fi

DIFF_SEC=$((NOW_TIMESTAMP_SEC - DEPLOYED_LAST_DEPARTURE_SEC));
DIFF_DAYS=$((DIFF_SEC / 86400));
echo ">> Deployed data has expired! Last departure was $DIFF_DAYS days ago.";
if [[ "$DEPLOYED_LAST_DEPARTURE_SEC" -gt "$NOW_TIMESTAMP_SEC" ]]; then
DIFF_SEC=$((DEPLOYED_LAST_DEPARTURE_SEC - NOW_TIMESTAMP_SEC));
DIFF_DAYS=$((DIFF_SEC / 86400));
echo ">> Deployed data expires in $DIFF_DAYS days (within 3 days). Sync recommended.";
else
DIFF_SEC=$((NOW_TIMESTAMP_SEC - DEPLOYED_LAST_DEPARTURE_SEC));
DIFF_DAYS=$((DIFF_SEC / 86400));
echo ">> Deployed data has expired! Last departure was $DIFF_DAYS days ago.";
fi
echo ">> Data is OUTDATED. Sync recommended. Looking for available archives...";

# Check archive directory for available data
Expand Down
4 changes: 2 additions & 2 deletions shared-overwrite/.github/workflows/mt-check-data-outdated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name: MT check data outdated
on:
workflow_dispatch: # manual
schedule:
- cron: '0 12 * * 0,1,3,4,6' # Mon, Wed, Thu, Sat & Sun @ 12pm UTC # https://crontab.guru/#0_12_*_*_0,1,3,4,6
# schedule: # DISABLED
# - cron: '0 12 * * 0,1,3,4,6' # Mon, Wed, Thu, Sat & Sun @ 12pm UTC # https://crontab.guru/#0_12_*_*_0,1,3,4,6
# gh workflow run mt-check-data-outdated.yml --ref $(git rev-parse --abbrev-ref HEAD)
# gh run list --workflow=mt-check-data-outdated.yml
concurrency:
Expand Down