diff --git a/src/cli/data.py b/src/cli/data.py index 1fe53c5..95f5738 100644 --- a/src/cli/data.py +++ b/src/cli/data.py @@ -193,5 +193,9 @@ def push_metric(client, competition, metric): def push_pit(client, competition, pit): for variable in pit: + + push_team_pit_data(apikey, competition, variable, pit[variable]) - push_team_pit_data(client, competition, variable, pit[variable]) \ No newline at end of file +def check_new_database_matches(client, competition): + + return True \ No newline at end of file diff --git a/src/cli/superscript.py b/src/cli/superscript.py index d161fe7..791a960 100644 --- a/src/cli/superscript.py +++ b/src/cli/superscript.py @@ -164,7 +164,7 @@ import warnings import websockets from interface import splash, log, ERR, INF, stdout, stderr -from data import get_previous_time, pull_new_tba_matches, set_current_time, load_match, push_match, load_pit, push_pit, get_database_config, set_database_config +from data import get_previous_time, pull_new_tba_matches, set_current_time, load_match, push_match, load_pit, push_pit, get_database_config, set_database_config, check_new_database_matches from processing import matchloop, metricloop, pitloop config_path = "config.json" @@ -216,11 +216,10 @@ sample_json = """{ "strategic-focus":true, "climb-mechanism":true, "attitude":true - } - }, - "even-delay":false, - "loop-delay":60 - } + }, + "event-delay":false, + "loop-delay":60 + } }""" def main(send, verbose = False, profile = False, debug = False): @@ -315,11 +314,20 @@ def main(send, verbose = False, profile = False, debug = False): if profile: return # return instead of break to avoid sys.exit - loop_delay = float(config["variable"]["loop-delay"]) - remaining_time = loop_delay - (time.time() - loop_start) - if remaining_time > 0: - send(stdout, INF, "loop delayed by " + str(remaining_time) + " seconds") - time.sleep(remaining_time) + event_delay = config["event-delay"] + if event_delay: + send(stdout, INF, "loop delayed until database returns new matches") + new_match = False + while not new_match: + time.sleep(1) + new_match = check_new_database_matches(client, competition) + send(stdout, INF, "database returned new matches") + else: + loop_delay = float(config["loop-delay"]) + remaining_time = loop_delay - (time.time() - loop_start) + if remaining_time > 0: + send(stdout, INF, "loop delayed by " + str(remaining_time) + " seconds") + time.sleep(remaining_time) except KeyboardInterrupt: send(stdout, INF, "detected KeyboardInterrupt, killing threads")