Added support for filtering at the individual stat level

reminder
Etzelia 2018-10-21 16:40:47 -05:00
parent cfeabc3727
commit d35b77014f
1 changed files with 8 additions and 4 deletions

12
external/stats.py vendored
View File

@ -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