Skip to content

Instantly share code, notes, and snippets.

@tripleee
Created March 29, 2017 12:40
Show Gist options
  • Save tripleee/307c0f5981b38e056e51cd3656716549 to your computer and use it in GitHub Desktop.
Save tripleee/307c0f5981b38e056e51cd3656716549 to your computer and use it in GitHub Desktop.
Average deletion time from Metasmoke JSON dump
#!/usr/bin/env python
import sys, json
from datetime import datetime, timedelta
with open(sys.argv[1], 'r') as input:
j = json.load(input)
deleted = list()
alive = list()
for i in j:
if 'deleted_at' in i and i['deleted_at'] is not None:
for k in ['created_at', 'deleted_at']:
i['epoch_' + k] = datetime.strptime(i[k].split('.')[0],
'%Y-%m-%dT%H:%M:%S')
delta = i['epoch_deleted_at'] - i['epoch_created_at']
i['lived'] = delta.total_seconds()
deleted.append(i)
else:
i['alive'] = True
alive.append(i)
print("alive: {0}".format(len(alive)))
print("dead: {0}".format(len(deleted)))
print("average lifespan: {0}".format(sum([x['lived'] for x in deleted])/len(deleted)))
print("")
# These are actually probably deleted, just not in Metasmoke's database (it stops looking after a while)
for a in alive:
print("{0} https://{1}".format(a['created_at'], a['link']))
@tripleee
Copy link
Author

@tripleee
Copy link
Author

For Graphics Design, as of a bit earlier today, 7 "alive" (which were actually all deleted) and average lifespan for the rest 183.405376344 seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment