diff --git a/external/stats.py b/external/stats.py index 94b8764..dad52c6 100644 --- a/external/stats.py +++ b/external/stats.py @@ -1,4 +1,4 @@ -import os, json +import os, json, copy from minecraft_manager.models import Player from django.conf import settings @@ -16,9 +16,13 @@ def get_stats(): with open(stats_dir + "/" + filename) as json_file: raw = json.load(json_file)['stats'] clean = {} - for r in raw: - if not any(sf.lower() in r.lower() for sf in stats_filter): - clean[r] = raw[r] + raw_copy = copy.deepcopy(raw) + for ra in raw_copy: + if not any(sf.lower() in ra.lower() for sf in stats_filter): + for r in raw_copy[ra]: + if any(sf.lower() in r.lower() for sf in stats_filter): + del raw[ra][r] + clean[ra] = raw[ra] uuid = filename.replace(".json", "") stats[uuid] = clean return stats