#!/bin/bash

# Check that dependencies are installed before going further
if [ -z "$(command -v curl)" ]; then
    echo "This script needs curl to be installed."
    exit 1
fi
if [ -z "$(command -v python3)" ]; then
    echo "This script needs python3 to be installed."
    exit 1
fi
./scripts/check-python-deps.py
if [ "$?" != 0 ]; then
    echo "This script needs numpy to be installed."
    exit 1
fi

# Get bridge data
if [ "$1" == "--fast" ]; then
    echo "Extracting some pre-processed data..."
    cd data && tar xf bridge_data.tar.gz && cd ..
else
    echo "Downloading and processing data from step 1..."
    echo "This will take quite a long time (around 12.5 hours on my device)"
    echo "and require a few GB of free space while running."
    ./scripts/get-bridge-data.sh
fi

# Get list of email-distributed bridges
./scripts/get-email-bridges.sh

# Clean up bridge data for the format we want
./scripts/clean-bridge-data.sh

# Evaluate blockages and get stats
./scripts/get-stats.sh
