Created
July 29, 2020 18:35
-
-
Save Sobsz/11bd307e20303abd1807bebe6c3f8721 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
with open("instance_list.json", "r") as f: | |
instances_orig = json.loads(f.read())["instances"] | |
while True: | |
instances = instances_orig.copy() # in case you wanna run multiple analysises which you do | |
if input("type \"a\" for counting active, none for users: ") == "a": | |
user_key = "active_users" | |
else: | |
user_key = "users" | |
if input("\"a\" to exclude instances with 0 active users, none for count all: ") == "a": # afaict there are no 0-user instances | |
for i in reversed(range(len(instances))): | |
if instances[i]["active_users"] == None: | |
del instances[i] | |
print(len(instances), "instances in list") | |
users = sum([int(i[user_key] or 0) for i in instances]) | |
top = [{"users": 0} for i in range(25)] # top instance count here because i didn't feel like constantsing | |
for i in instances: # i refuse to add pandas for this one thing | |
for j in range(len(top)): | |
if int(i["users"] or 0) > int(top[j]["users"]): # not active users for consistency | |
top.insert(j, i) | |
top.pop() | |
break | |
print("top instances:") | |
for i in range(len(top)): | |
print(str(i+1), "\t-", top[i]["name"], "with", top[i]["users"], "users") | |
cutoff = int(input("ignore top x instances: ") or 0) | |
for i in range(cutoff): users -= int(top[i][user_key] or 0) | |
print(users, "users total,", "{0:0.2f}".format(users / (len(instances) - cutoff)), "per instance") | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment