forked from Minecraft/minecraft_manager
Added support for filtering at the individual stat level
parent
cfeabc3727
commit
d35b77014f
|
@ -1,4 +1,4 @@
|
||||||
import os, json
|
import os, json, copy
|
||||||
from minecraft_manager.models import Player
|
from minecraft_manager.models import Player
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
@ -16,9 +16,13 @@ def get_stats():
|
||||||
with open(stats_dir + "/" + filename) as json_file:
|
with open(stats_dir + "/" + filename) as json_file:
|
||||||
raw = json.load(json_file)['stats']
|
raw = json.load(json_file)['stats']
|
||||||
clean = {}
|
clean = {}
|
||||||
for r in raw:
|
raw_copy = copy.deepcopy(raw)
|
||||||
if not any(sf.lower() in r.lower() for sf in stats_filter):
|
for ra in raw_copy:
|
||||||
clean[r] = raw[r]
|
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", "")
|
uuid = filename.replace(".json", "")
|
||||||
stats[uuid] = clean
|
stats[uuid] = clean
|
||||||
return stats
|
return stats
|
||||||
|
|
Loading…
Reference in New Issue