diff --git a/src/cli/data.py b/src/cli/data.py index 641aba7..fb5dc27 100644 --- a/src/cli/data.py +++ b/src/cli/data.py @@ -1,7 +1,6 @@ import requests import pymongo import pandas as pd -import time def pull_new_tba_matches(apikey, competition, cutoff): api_key= apikey @@ -55,7 +54,7 @@ def get_metrics_data_formatted(apikey, competition): out = {} for i in x: try: - out[int(i)] = d.get_team_metrics_data(apikey, competition, int(i)) + out[int(i)] = get_team_metrics_data(apikey, competition, int(i)) except: pass return out @@ -126,4 +125,77 @@ def unkeyify_2l(layered_dict): add.append([j,layered_dict[i][j]]) add.sort(key = lambda x: x[0]) out[i] = list(map(lambda x: x[1], add)) - return out \ No newline at end of file + return out + +def get_previous_time(apikey): + + previous_time = get_analysis_flags(apikey, "latest_update") + + if previous_time == None: + + set_analysis_flags(apikey, "latest_update", 0) + previous_time = 0 + + else: + + previous_time = previous_time["latest_update"] + + return previous_time + +def set_current_time(apikey, current_time): + + set_analysis_flags(apikey, "latest_update", {"latest_update":current_time}) + +def load_match(apikey, competition): + + return get_match_data_formatted(apikey, competition) + +def load_metric(apikey, competition, match, group_name, metrics): + + group = {} + + for team in match[group_name]: + + db_data = get_team_metrics_data(apikey, competition, team) + + if get_team_metrics_data(apikey, competition, team) == None: + + elo = {"score": metrics["elo"]["score"]} + gl2 = {"score": metrics["gl2"]["score"], "rd": metrics["gl2"]["rd"], "vol": metrics["gl2"]["vol"]} + ts = {"mu": metrics["ts"]["mu"], "sigm+a": metrics["ts"]["sigma"]} + + group[team] = {"elo": elo, "gl2": gl2, "ts": ts} + + else: + + metrics = db_data["metrics"] + + elo = metrics["elo"] + gl2 = metrics["gl2"] + ts = metrics["ts"] + + group[team] = {"elo": elo, "gl2": gl2, "ts": ts} + + return group + +def load_pit(apikey, competition): + + return get_pit_data_formatted(apikey, competition) + +def push_match(apikey, competition, results): + + for team in results: + + push_team_tests_data(apikey, competition, team, results[team]) + +def push_metric(apikey, competition, metric): + + for team in metric: + + push_team_metrics_data(apikey, competition, team, metric[team]) + +def push_pit(apikey, competition, pit): + + for variable in pit: + + push_team_pit_data(apikey, competition, variable, pit[variable]) \ No newline at end of file diff --git a/src/cli/dataset.py b/src/cli/dataset.py deleted file mode 100644 index 5a69cc9..0000000 --- a/src/cli/dataset.py +++ /dev/null @@ -1,74 +0,0 @@ -import data as d - -def get_previous_time(apikey): - - previous_time = d.get_analysis_flags(apikey, "latest_update") - - if previous_time == None: - - d.set_analysis_flags(apikey, "latest_update", 0) - previous_time = 0 - - else: - - previous_time = previous_time["latest_update"] - - return previous_time - -def set_current_time(apikey, current_time): - - d.set_analysis_flags(apikey, "latest_update", {"latest_update":current_time}) - -def load_match(apikey, competition): - - return d.get_match_data_formatted(apikey, competition) - -def load_metric(apikey, competition, match, group_name, metrics): - - group = {} - - for team in match[group_name]: - - db_data = d.get_team_metrics_data(apikey, competition, team) - - if d.get_team_metrics_data(apikey, competition, team) == None: - - elo = {"score": metrics["elo"]["score"]} - gl2 = {"score": metrics["gl2"]["score"], "rd": metrics["gl2"]["rd"], "vol": metrics["gl2"]["vol"]} - ts = {"mu": metrics["ts"]["mu"], "sigm+a": metrics["ts"]["sigma"]} - - group[team] = {"elo": elo, "gl2": gl2, "ts": ts} - - else: - - metrics = db_data["metrics"] - - elo = metrics["elo"] - gl2 = metrics["gl2"] - ts = metrics["ts"] - - group[team] = {"elo": elo, "gl2": gl2, "ts": ts} - - return group - -def load_pit(apikey, competition): - - return d.get_pit_data_formatted(apikey, competition) - -def push_match(apikey, competition, results): - - for team in results: - - d.push_team_tests_data(apikey, competition, team, results[team]) - -def push_metric(apikey, competition, metric): - - for team in metric: - - d.push_team_metrics_data(apikey, competition, team, metric[team]) - -def push_pit(apikey, competition, pit): - - for variable in pit: - - d.push_team_pit_data(apikey, competition, variable, pit[variable]) \ No newline at end of file diff --git a/src/cli/processing.py b/src/cli/processing.py index 3778926..dd5ee2f 100644 --- a/src/cli/processing.py +++ b/src/cli/processing.py @@ -1,7 +1,7 @@ import numpy as np from tra_analysis import Analysis as an -from dataset import push_metric +from dataset import push_metric, load_metric from data import pull_new_tba_matches import signal diff --git a/src/cli/superscript.spec b/src/cli/superscript.spec index 5ffc4bf..04cafa7 100644 --- a/src/cli/superscript.spec +++ b/src/cli/superscript.spec @@ -2,7 +2,6 @@ block_cipher = None - a = Analysis(['superscript.py'], pathex=['/workspaces/tra-data-analysis/src'], binaries=[],