# script to wait for WA case numbers to be released

import time
from datetime import datetime, timedelta
from get_wa_cases import get_cases
from reff_plots_common import covidlive_summary_data

def press_release_today():
    try:
        yesterday = f"{datetime.now() - timedelta(days=1):%Y-%m-%d}"
        if yesterday in get_cases():
            covidlive_summary_data('wa')
            return True
        return False
    except Exception as e:
        print(e)
        return False


if __name__ == '__main__':
    # Check once every 5 minutes for a press release
    while not press_release_today():
        time.sleep(300)
    print("ready!")
