Created
March 13, 2017 18:39
-
-
Save fangeugene/0581ceec1eb88f629b13f5d3f1700bd8 to your computer and use it in GitHub Desktop.
Count Top Team Subscriptions
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
from models.subscription import Subscription | |
from collections import defaultdict | |
counts = defaultdict(int) | |
for s in Subscription.query(Subscription.model_type==1).fetch(): | |
counts[s.model_key] += 1 | |
sorted_counts = sorted(counts.items(), key=lambda x: -x[1]) | |
for team, count in sorted_counts[:100]: | |
print team, count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment